mCore DataSheet


#1

Hi,
I’m new in the mBlock word . I made some programs with scratch but I would like to program my mBot directly with Arduino.
For that, I compare the program did with scratch and I use also example in the Makeblock library.
But I would like to understand how to use in more simple way the green button for example.
If I look in the setup I have

pinMode(A7,INPUT);

Does any one can explain it to me ?

There is is a possibility to have directly an Boolean ?


Where is the Analog Pin On Mbot
#2

This statement means set Analog pin 7 (A7) as an input. Since the green button on the mBot is a momentary contact, normally open switch (meaning that the switch only closes a circuit when pressed), the program will detect the switch being closed and will return a value from Analog pin A7.


#3

Thanks for your help.


#4

Hi,
I test reading the green button by programming it :
in the void setup
pinMode(A7,INPUT)

in the void loop
I test the green button with an digitalRead

if (digitalRead==true) { … nothing append

I replace true by HIGH, LOW 0 ,but no reaction

If I want a reaction, I need to use this code

if ((0^(analogRead(A7)>10?0:1))) { …

I visit the arduino web site for understanding the code : ^ is an XOR function but “?” and “:” I don’t find

Does anyone know ?
and why can’t I read A7 directly with digitalread ?


#5

If you set the pin up as an analog pin, you likely need to use the analogRead method, not the digitalRead method. :slight_smile:


#6

One more update on this. The values for the pushbutton are 0 when pressed and 1023 when released. Hope this helps.

One more thing. The pin is set up on analog pin 7 and can only be read using the analogRead method.


#7