Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
#include <iostream> #include <bitset> using namespace std; int left_sensor_white; int left_sensor_black; int right_sensor_white; int right_sensor_black; int th_r; int th_l; int ADC_R,ADC_L; // getting new values from Right , Left Sensors unsigned char byte; void main(){ bool right; bool left; cin>>left_sensor_white; cin>>left_sensor_black; cin>>right_sensor_white; cin>>right_sensor_black; th_r= (right_sensor_white + right_sensor_black)/2; th_l= (left_sensor_black + left_sensor_black)/2; cout<<" TH_Right_Sensor"<<th_r<<endl; cout<<"TH_Left_Sensor"<<th_l<<endl; while(1) { cout<<"Input new values from the sensors"<<endl; cin>>ADC_R; cin>>ADC_L; if ( ADC_R >= th_r) { right=1; } else {right=0;}; if( ADC_L >= th_l){left=1;} else {left=0;} cout<<" LEFT"<<left<<"Right"<<right<<endl; }}
cin>>left_sensor_white;cin>>left_sensor_black;while(button=0);//wait until you move robot so sensors can see other conditioncin>>right_sensor_white;cin>>right_sensor_black;
th_r= right_sensor_white/2 + right_sensor_black/2;th_l= left_sensor_black/2 + left_sensor_black/2;