Go Down

Topic: Plug sensor on robot  (Read 43 times) previous topic - next topic

briag

Hello,

We were wondering how to plug sensor on the robot. We try to plug a push buton on M2 port, we would like that when this button is in high state the robot move.

Code: [Select]
#include <ArduinoRobot.h>
#include <Wire.h>[table]
#include <SPI.h>
 
 int buttonState = 0;
 const int bp=M2;
void setup(){
   Robot.begin(); // initialize the library
      pinMode(bp, INPUT);     
}

void loop(){
     buttonState = digitalRead(bp);
      if (buttonState == HIGH) {     
   Robot.motorsWrite(50,50);
   
      }
   else {
   Robot.motorsWrite(0,0); // stop moving
   

   }
      }
 

Thank you.

weedpharma

I do not understand what you want.

What type of sensor?

What type of motor?


Give a full description of your equipment and what you want to happen.

Weedpharma

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy