Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial softSerial(11, 8); //TX_BT --> D11 / RX_BT --> D8
- int sensorPIN = A1;
- int sensor_status = 0;
- int thumbPIN = A0;
- int thumb_status = 0;
- void setup() {
- Serial.begin(9600);
- softSerial.begin(9600);//38400
- pinMode(sensorPIN, INPUT);
- pinMode(thumbPIN, INPUT);
- delay(500);
- }
- void loop() {
- sensor_status = analogRead(sensorPIN);
- thumb_status = analogRead(thumbPIN);
- Serial.print(sensor_status);
- Serial.print("\t\t");
- Serial.println(thumb_status);
- if (sensor_status < 900 && thumb_status > 100) {
- softSerial.write(1);
- Serial.println("1");
- }
- else if (sensor_status > 900 && thumb_status < 100) {
- softSerial.write(2);
- Serial.println("2");
- }
- else if (sensor_status > 900 && thumb_status > 100) {
- softSerial.write(3);
- Serial.println("3");
- }
- else if (sensor_status < 900 && thumb_status < 100) {
- softSerial.write(4);
- Serial.println("4");
- }
- delay(1000);
- }//end of LOOP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement