More than Just Lines on a Map: Best Practices for U.S Bike Routes
code-arduino-uno-R3.docx
1. #include <ArduinoJson.h>
#include <ThreeWire.h>
#include <RtcDS1302.h>
#include<DHT.h>
#include <SoftwareSerial.h>
#include <BH1750.h>
#include <Wire.h>
#define sensor A3
const byte Rx= 8;
const byte Tx =9;
SoftwareSerial myserial=SoftwareSerial(Rx,Tx); //Rx-Tx
ThreeWire myWire(13, 12, 3); // IO, SCLK, CE
RtcDS1302<ThreeWire> Rtc(myWire);
const int DHTPIN = 2; //Đọc dữ liệu từ DHT11 ở chân 2 trên mạch Arduino
const int DHTTYPE = DHT11; //Khai báo loại cảm biến, có 2 loại là DHT11 và DHT2
DHT dht(DHTPIN, DHTTYPE);
BH1750 lightMeter; // cường độ sáng
int bom = 7;
int led = 6;
int quat= 5;
int trang_thai_bom;
int trang_thai_led;
int trang_thai_quat;
int pump_nhan;
int led_nhan;
int quat_nhan;
int che_do;
int nhiet_do_dat;
int do_am_dat_dat;
float do_am_thuc; //a
float nhiet_do_thuc; //b
2. float lux_thuc; //c
float do_am_dat_thuc;//d
String DataSend= "";
String Dataesp = "";
void Json(String thamso1, String thamso2, String thamso3, String thamso4 , String
thamso5,String thamso6);
void xulyjson(String Data);
void chuongtrinhcambien(void);
void read_uno(void);
long t = 0;
// ham khoi tao
void setup() {
// khởi tạo cổng uart chính thống
myserial.begin(9600);// khởi tạo cổng uart => tx,rx(0,1) tốc độ truyền 9600
Serial.begin(9600);
Wire.begin(); // cường độ sáng SCL and SDA pins using a5 ,a4
dht.begin(); // Khởi động cảm biến
lightMeter.begin();
t= millis();
pinMode(bom, OUTPUT);
pinMode(led, OUTPUT);
pinMode(sensor, INPUT);
pinMode(quat, OUTPUT);
Serial.print("compiled: ");
Serial.print(__DATE__);
Serial.println(__TIME__);
Rtc.Begin();
RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__);
printDateTime(compiled);
Serial.println();
}
//////////////////////ham chinh
void loop() {