Simple program for leds and buttons


#1

I have just started with mblock and used the Arduino IDE software before.
I managed to easily assign some buttons and led’s and I am able to control the led’s with the buttons.

Until I installed mblock and expected to do the same, start easily with some buttons and leds.

I managed to get the led’s working, but I have no idea on how to control them with one or more buttons.

I don’t see the default items to control a button. how do I do this ?


#2

Which buttons? Hardware buutons or software?
What exactly did you already try?


#3

It’s a hardware button.
I have been searching on the internet for hours, but didn’t find anything.

I can’t find anything in mBlock itself used to configure a hardware button.
Programming the led’s wasn’t a problem at all, but I am quite surprised that I didn’t find anything to program a hardware button.

Any suggestions are more than welcome.


#4

In a lot of youtube movies I see the program code .
Althoug not in my application. (v3.4.3)

How come ?


#5

See the code above … that works fine with my mBot, also using mBlock 3.4.3. This will work in Arduino mode only, you will need to upload it to mBot using USB cable. If you want to return to the online mode, you need to restore the default program first.

I first tried to use the online more (with the green flag to start), but that did not work. In online mode, pressing the button starts the motors to run in random directions. Strange. Does someone know if that is a bug?

Anyway, you try to tell us that in your mBlock installation, the “on board button” block is not available in the robots section?
Do you have the robots section?
Maybe you have the wrong board selected? Check the Boards menue and select the correct board.


#6

Sorry that I didn’t mention, but I have additional buttons on my breadboard as wel as several led’s I would like to program.
The only option I have is the one you mention, which is "on board button …"
But I don’t want to program the on board button but several other buttons.

How do I achieve that ?


#7

Which breadboard? Which robot are you using? How do you connect that?

Without knowing the answers … you could try to use the microswitch module in mBlock. You could use the RJ25 adaptor module and connect it with m/f jumper wires to your breadboard. Then check the button state using the microswitch module in mBlock.


#8

I am using a very basic configuration, which look likes the following circuit with similar breadboard. how do I program these buttons ?


#9

Ah ok. I think the easiest is to look for any Arduino tutorial in the web and use the Arduino IDE to program it.


#10

I have been told that Mblock is good to use, so I installed it and it looks very nice.
It also has many options to program a robot, so I can hardly believe that it isn’t possible to program this button.
Anyone a suggestion ?


#11

The Makeblock team extended Scratch with elements for their electronic modules. So you can use Scratch on the PC and also the mobile apps which they provide using a graphical programming.

However you try to connect arbitrary components directly to an Arduino Uno. That’s just not in scope of the Makeblock system. mBlock is not a generic graphical programming alternative to the regular Arduino IDE.


#12

I just found that there is a scratch variant for Arduino boards … maybe that suits your use case better:
http://s4a.cat/


#13