Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int LDR = 3;
- int laser = 4;
- boolean state = false;
- float lower=2.2;
- float upper=3.3;
- int a =0;
- void setup(){
- pinMode(LDR,INPUT);
- pinMode(laser,OUTPUT);
- }
- void loop() {
- //State A = flase , State B = true
- int sensorValue = analogRead(LDR);
- float voltage = sensorValue * (5.0 / 1023.0);
- //State A with input X = 0 =---> Stay At A with output 0
- if(voltage<lower && state==false ){
- a=0;
- }//State A with input X = 1 =---> Go to B with output 0
- else if(voltage>upper && state==false){
- state=true;
- a=0;
- }//State B with input X = 0 =---> Stay at B with output 0
- else if(voltage<lower && state==true){
- a=0
- }//State B with input X = 1 =---> Switch to A with output 1
- else if(voltage>upper && state == true){
- state=false;
- a=1;
- }
- delay(30);
- /*if(a==(output of the sensor of the other machine ))
- {
- true or false;
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement