Advertisement
safwan092

Untitled

May 15th, 2022
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2.  
  3. SoftwareSerial softSerial(11, 8); //TX_BT --> D11 / RX_BT --> D8
  4.  
  5. int sensorPIN = A1;
  6. int sensor_status = 0;
  7.  
  8. int thumbPIN = A0;
  9. int thumb_status = 0;
  10.  
  11. void setup() {
  12. Serial.begin(9600);
  13. softSerial.begin(9600);//38400
  14. pinMode(sensorPIN, INPUT);
  15. pinMode(thumbPIN, INPUT);
  16. delay(500);
  17. }
  18.  
  19. void loop() {
  20. sensor_status = analogRead(sensorPIN);
  21. thumb_status = analogRead(thumbPIN);
  22. Serial.print(sensor_status);
  23. Serial.print("\t\t");
  24. Serial.println(thumb_status);
  25.  
  26. if (sensor_status < 900 && thumb_status > 100) {
  27. softSerial.write(1);
  28. Serial.println("1");
  29. }
  30. else if (sensor_status > 900 && thumb_status < 100) {
  31. softSerial.write(2);
  32. Serial.println("2");
  33. }
  34. else if (sensor_status > 900 && thumb_status > 100) {
  35. softSerial.write(3);
  36. Serial.println("3");
  37. }
  38. else if (sensor_status < 900 && thumb_status < 100) {
  39. softSerial.write(4);
  40. Serial.println("4");
  41. }
  42. delay(1000);
  43. }//end of LOOP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement