Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int motorPin1 = 9; // Pin 14 of L293
- const int motorPin2 = 10; // Pin 10 of L293
- const int isenabled = XX;
- const int ismanual = XX;
- const int isautomatic = XX;
- const int btn_up = XX;
- const int btn_down = XX;
- //Motor B
- //const int motorPin3 = 6; // Pin 7 of L293
- //const int motorPin4 = 5; // Pin 2 of L293
- #define distance 7000
- void setup() {
- // put your setup code here, to run once:
- pinMode(motorPin1, OUTPUT);
- pinMode(motorPin2, OUTPUT);
- pinMode(isenabled,INPUT);
- pinMode(isautomatic,INPUT);
- pinMode(ismanual,INPUT);
- pinMode(btn_dow1n,INPUT);
- pinMode(btn_up,INPUT);
- }
- void loop() {
- if(isenabled == HIGH){
- if(ismanual == HIGH){
- while(ismanual == HIGH){
- if(btn_up == HIGH){
- while(btn_up == HIGH){
- analogWrite(motorPin1,200);//end utga ni ymar neg too bn.
- analogWrite(motorPin2,0);
- }
- }
- if(btn_down == HIGH){
- while(btn_down == HIGH){
- analogWrite(motorPin1,200);
- analogWrite(motorPin2,10);//end utga ni ymar neg too bn.
- }
- }
- }
- }
- else if(isautomatic == HIGH){
- if (lightvalue > 750)
- {
- analogWrite(motorPin1,distance);
- analogWrite(motorPin2,0);
- }
- else if(lightvalue < 350)
- {
- analogWrite(motorPin1,0);
- analogWrite(motorPin2,distance);
- }
- }
- else{
- delay(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement