The block switches on the pin you choose in the list
The block switches on the port you choose for a certain time.
You need to add a variable on the to say for how long i.e. 1000 for 1 second
Afterwards the pin will be switched of for the same amount of time. Note: a LED would blink.
The block switches the pin you choose off. NOTE: on and off might be different from what you expect as they also depend on your circuit.
The block can be used for everything you want to do after reading a value from a switch/sensor.
Choose where you connected the switch/sensor and choose the treshold. You can try out what values
you get by using the Monitor block before. Drag for example an On Block right to the if block to switch on an LED after pressing a button.
Note: if you do not add a second if statement below with the opposite values the LED will be on forever
Here is an example how to use the if block: First ask i.e. if the sensor value on pin 3 is more then 500 then drag an on block to right. Then ask in another if block if the sensor value on pin 3 is less then 500 and drag on off block next to it. Now you can go on with your programm under the second if block
Can be used instead of “if”. Waits till a certain event (i.e. Switch is pressed happens).
Can be used to show data of a sensor or switch back on your computer. It is very usefull to find out what kind of values you get. NOTE: to see the values you must click on the “Serial Monitor” after uploading your program.
Pauses the program for the duration of a variable you have to add.The duration is in Microseconds so use 1000 if you want to stop for a second.
One Response to “What does each Block do?”
but I had a small problem with the IF block – I pulled one ON next to IF and an OFF block below the block. The problem is probably bad translation from blocks to the code view – the part of the code that switched the digital pin off was out of “else” brackets in the code view – I had to cut/paste it a few lines up to make it work correctly.
But this was just one small example of how the code view can be useful…
Leave a Reply