Guest User

Untitled

a guest
Jan 11th, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. ----------------------
  2. For the UNO
  3. ----------------------
  4. int input = 13;
  5. bool status;
  6.  
  7. void setup()
  8. {
  9. pinMode(input, INPUT);
  10. Serial.begin(9600);
  11. }
  12. void loop(){
  13.  
  14. if(digitalRead(input) == HIGH){
  15. status = true;
  16. }
  17. if(digitalRead(input) == LOW){
  18. status = false;
  19. }
  20. Serial.println(status);
  21.  
  22. }
  23. ----------------------
  24. For the ESP
  25. ----------------------
  26.  
  27. int outputPin = 10;
  28.  
  29. void setup(){
  30. pinMode(outputPin, OUTPUT);
  31. }
  32. //other code yadda yadda
  33.  
  34. void turnOn(String deviceId){
  35. if(deviceID == DEVICE1){
  36. digitalWrite(outputPin, HIGH);
  37. }
  38. }
  39. void turnOff(String deviceId){
  40. if(deviceID == DEVICE1){
  41. digitalWrite(outputPin, LOW);
  42. }
  43. }
  44.  
  45. //now making an LED turn on and off with digitalWrite will work fine. So the yadda yadda code works. Its just when to turn the "device" on or off to carry out the HIGH and LOW will not pass and gives HIGH/LOW constantly
Add Comment
Please, Sign In to add comment