Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int OUT1 = 2; // OUT1 is the output signal 1
- int OUT2 = 3; // OUT2 is the output signal 2
- int OUT3 = 4; // OUT3 is the output signal 3
- int LED7 = 5; // OUT3 is the output signal 3
- int LEDOUT1 = 6; // LEDOUT1 is the feedback for OUT1
- int LEDOUT2 = 7; // LEDOUT2 is the feedback for OUT2
- int LEDOUT3 = 8; // LEDOUT3 is the feedback for OUT3
- int LEDOUT4 = 9; // LEDOUT3 is the feedback for OUT3
- int LEDSENSOR = 13;
- int LEDSTATE1 = 0;
- int LEDSTATE2 = 0;
- int LEDSTATE3 = 0;
- int MasterState1 = 0;
- int MasterState2 = 0;
- int forceSensor = 1; // forceSensor is connected to A0 to reading the forceSensor data
- int readingForceSensor; // variable to reading the forceSensor data
- void setup() {
- Serial.begin(9600);
- pinMode(OUT1, OUTPUT); // declare OUT1 (digital pin 2) as an output
- pinMode(OUT2, OUTPUT); // declare OUT2 (digital pin 3) as an output
- pinMode(OUT3, OUTPUT); // declare OUT3 (digital pin 4) as an output
- pinMode(LEDOUT1, OUTPUT); // declare LEDOUT1 (digital pin 5) as an output
- pinMode(LEDOUT2, OUTPUT); // declare LEDOUT2 (digital pin 6) as an output
- pinMode(LEDOUT3, OUTPUT); // declare LEDOUT3 (digital pin 7) as an output
- pinMode(LEDOUT4, OUTPUT); // declare LEDOUT3 (digital pin 7) as an output
- pinMode(LEDSENSOR, OUTPUT);
- }
- void loop() {
- readingForceSensor = analogRead(forceSensor);
- if ((readingForceSensor > 10) && (readingForceSensor < 200))
- {
- digitalWrite(OUT1, HIGH);
- digitalWrite(LEDOUT1, HIGH);
- digitalWrite(LEDSENSOR, HIGH);
- }
- else
- {
- digitalWrite(OUT1, LOW);
- digitalWrite(LEDOUT1, LOW);
- }
- if ((readingForceSensor > 200) && (readingForceSensor < 400))
- {
- digitalWrite(OUT2, HIGH);
- digitalWrite(LEDOUT2, HIGH);
- digitalWrite(LEDSENSOR, HIGH);
- delay(200);
- digitalWrite(LEDSENSOR, LOW);
- delay(200);
- }
- else
- {
- digitalWrite(OUT2, LOW);
- digitalWrite(LEDOUT2, LOW);
- }
- if (readingForceSensor > 400) // if the force sensor is more than 400, OUT3 & LEDOUT3 gets a HIGH signal
- { // LEDSTATE3 goes HIGH
- digitalWrite(OUT3, HIGH); // OUTPUT 3 goes HIGH
- digitalWrite(LEDOUT3, HIGH);
- digitalWrite(LEDSENSOR, HIGH); // LED 1 goes HIGH} // LED 1 goes HIGH
- delay(70);
- digitalWrite(LEDSENSOR, LOW);
- delay(70);// LED 3 goes HIGH
- }
- else // if not the switchPin gives a LOW signal
- {
- digitalWrite(OUT3, LOW); // OUTPUT 3 goes LOW
- digitalWrite(LEDOUT3, LOW);
- }
- if (readingForceSensor < 1)
- {digitalWrite(LEDSENSOR, LOW);}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement