arduino websocket serial project
This commit is contained in:
BIN
C++/Arduino/Joystick_Mouse.rar
Normal file
BIN
C++/Arduino/Joystick_Mouse.rar
Normal file
Binary file not shown.
22
C++/Arduino/Servo_controller/Servo_controller.ino
Normal file
22
C++/Arduino/Servo_controller/Servo_controller.ino
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <Servo.h>
|
||||
#define SERVO_PIN 9
|
||||
#define XJOY_PIN A1
|
||||
Servo myservo ;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
myservo.attach(9);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(200);
|
||||
int joystickXVal = analogRead(XJOY_PIN) ; //read joystick input on pin A1
|
||||
Serial.print(joystickXVal); //print the value from A1
|
||||
Serial.println(" = input from joystick"); //print "=input from joystick" next to the value
|
||||
Serial.print((joystickXVal+520)/10); //print a from A1 calculated, scaled value
|
||||
Serial.println(" = output to servo"); //print "=output to servo" next to the value
|
||||
Serial.println() ;
|
||||
myservo.write((joystickXVal+520)/10); //write the calculated value to the servo
|
||||
}
|
||||
@@ -1,48 +1,25 @@
|
||||
lol#include <DHT.h>
|
||||
#include <DHT.h>
|
||||
#include <DHT_U.h>
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
#define DHTPIN 13
|
||||
#define DHTTYPE DHT11
|
||||
|
||||
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
|
||||
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
|
||||
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
lcd.begin(16, 2);
|
||||
Serial.begin(115200);
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
float humidity = dht.readHumidity();
|
||||
float temperature = dht.readTemperature();
|
||||
|
||||
if (isnan(temperature) || isnan(humidity)) {
|
||||
Serial.println("Failed to fetch");
|
||||
lcd.clear();
|
||||
lcd.print("Failed to fetch");
|
||||
if (isnan(temperature)) {
|
||||
Serial.println("-1000000");
|
||||
delay(500);
|
||||
return;
|
||||
}
|
||||
|
||||
String temp = (String)(int)temperature;
|
||||
String humid = (String)(int)humidity;
|
||||
|
||||
|
||||
String ln1 = "Temperature : " + temp + " °C";
|
||||
String ln2 = "Humidity : " + humid + " %";
|
||||
|
||||
Serial.println(ln1);
|
||||
Serial.println(ln2);
|
||||
Serial.println();
|
||||
|
||||
lcd.setCursor(0,0);
|
||||
lcd.print(ln1);
|
||||
lcd.setCursor(0,1);
|
||||
lcd.print(ln2);
|
||||
|
||||
delay(500);
|
||||
Serial.println((String)temperature);
|
||||
delay(30);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user