2015年10月20日 星期二

A Joystick example for Connecting arduino to mblock (scratch 2.0)(一個arduino連結到mblock的範例-搖桿使用)





       This  example show  how to connect the arduino to mblock(actually,it is scratch 2.0).
       I used one arduino UNO and one joystick.the H/W connection like below <picture 1>.
       please pay attation, I connect the joystick VCC to 3.3V not 5V.  
       than connected the USB to computuer usb port.


<Picture 1> Arduino UNO+ Joystick







<Picture 2> after connecting the arduino uno to PC USB port,you can check which serial port be used in your computer.




<Picture 3>Opem mblock to select the serial port which in your PC  device manager<Picture 2>  .Here is COM5.


<Picture 4> Select Arduino UNO board.IF you use other Arduino board like as Mega or nano.just select which board you used.



<Picture 5> select Arduino.


<Picture 6> Select <firmware update> ,it will auto download the arduino firmware to your arduino  board. After download firmware then compeleted the connecting between arduino and mblock.




<Picture 7 >You can see one more block <Robots> .You can use it to progarm your arduino board.



<Picture 8> Below is my sample code for joystick.




DEMO: