I'm attaching a picture of my board which has the push button I want to use, but I cannot because I don't know what pin number should I write in my code.

my code:

int switchPin = Button;
int ledPin =13;

void setup() {
  // put your setup code here, to run once:
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);

void loop() {
  // put your main code here, to run repeatedly:
if(digitalRead(switchPin) == HIGH)
  digitalWrite(ledPin, HIGH);
  digitalWrite(ledPin, LOW);

This is a picture shows the button on the top right "green"

  • 1
    Datasheet says? – Ignacio Vazquez-Abrams Sep 30 '16 at 18:13
  • 1
    What does the user manual say? I assume you have read it? – Majenko Sep 30 '16 at 18:15
  • @Majenko, what a strange assumption! – James Waldby - jwpat7 Sep 30 '16 at 18:20
  • @jwpat7 Well, one lives in hope that maybe someone will try reading the manual before they come here... – Majenko Sep 30 '16 at 18:21
  • 2
    Abdulrahman, what's the name of the board, or what identifying text is on it, or what do you think it's called? – James Waldby - jwpat7 Sep 30 '16 at 18:24

The schematic at makeblock.com of the mbot mcore board shows switch S3 feeding pin A7, which is an analog input pin. Note, there is a deplorable 0.1 μF capacitor in parallel across S3, probably intended as hardware-level debouncing.

Also see the Port wiring mBot mCore board thread at makeblock, where one of the posts says there are multiple versions of the board, and provides reference links.

For example, sample code at newinnovators.ca's “mblock-to-arduino/button-control” page shows pin 2 being used to sense the button. You may need to run some tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.