Now you know the potential of learning to program with scratch, as we have published app development classes using mit app inventor. Another amazing thing that you can do after learning to program in scratch is arduino. The beginning of robotics arduino is a microcontroller which is easily available from amazon or your local computer stores. The arduino can be bought alone or it can be bought with a kit which includes various sensors, which can help you make projects. So in this video im going to be showing you how to use the arduino with pictoblocks, which is a scratch based coding software, which you can use to program the arduino, so lets get started. So let me first tell you what an arduino is. An arduino is a microcontroller which is basically a small computer which you can program to make robots. So this is the arduino uno. There are various versions of arduino, but this is the easiest one to get your hands on and it is the best for beginners. So it is as big as a credit card and it looks fairly complicated at first, but i will be showing you how easy it is to code it later on. In the video on the side of the arduino. You can see a usb port and a power port on the top left. You can see a reset button is the arduino uno title and you can see digital inputs and outputs all over the board.

If you buy the arduino, it will also come with the cable, which might look like this. This is the usb cable which you use to program your arduino, it basically just connects to arduino like so, and the other end will connect to your computers, usb port. On the top of the arduino, you will see a row of pins. These are called a digital pins on the bottom of the arduino. You will see a row of pins or holes over here. These are called the analog pins and over here are ground and power pins. So that is a basic hardware. Description of the arduino now lets check out the software which we will use to program it. So this is the software which we will be using to program the arduino. Its name is pictoblox and if you have watched any of our previous scratch tutorial videos, you will immediately recognize this, as it looks just like scratch on the top, we have a few buttons to connect the arduino and over here it looks just fine just like scratch, But now lets connect our arduino to the software, so, as i showed before, you connect one side of the cable to your arduino and the other side to the computer. Now, once youve connected your arduino to your computer, be sure not to let it touch any metal surface as it could short out the arduino, which would not be good. Now this pop up might come over here you can register but im just going to cancel it for now now to connect the arduino.

We go to the port section over here and choose our board right now: im using the arduino uno, once thats done. This pop up will come over here and you should just connect the second one which is showing up com3 thats arduino board. You can even see that its official using the arduino llc lets just click connect, and it should show that its connected now there are two modes of this software stage mode and upload mode. You can see which mode youre on by looking at the top right. Right now were on stage mode, and basically what this means is that we can code our arduino real time and see its effects on the left over here. You will see that new modules have showed up, which are basically the arduino modules the on the top over here you will see your board name, arduino uno, and these are the basic blocks which well be using to code the arduino down. Here we can see blocks to make motors move blocks for sensors blocks for displays and blocks for dabble, which we will be discussing in another video. What were going to use right now are these blocks over here. So, first of all, you want to upload your firmware by clicking this button over here whenever youre in stage mode. You want to upload your firmware to make sure that your arduino works properly, so just wait for it to load, and now its done now lets make a simple project im going to be making a project right now, which will consist of the arduino blinking and led Light in morse code to show the initials of your name, my name is ahmad, so i want the arduino to blink the light.

To spell out a you can go on google to search for morse code translator and go to images, and you will see a whole list of images for more score. As you can see, a is a dot and a dash dot means small delay, meaning that the led will only turn on for a small amount of time and dash means a long delay. So the led will turn on for a long time. You can say that a dot can be 0.5 seconds and a dash can be one second, so dot dash means a and a stands for imad. So now were going to connect the led to the arduino. If you bought a kit with your arduino, you should already have these components, but if you dont, these components are widely available. All you need is, of course, your arduino, a small led. I already have a yellow one and a red one, but the color shouldnt really matter and a resistor. The resistor is there to reduce the current and make sure that our led doesnt accidentally blow, which can happen if you give away too much current so heres the arduino im going to choose a digital pin on the right side over here and preferably it should be On the top over here, so im going to be choosing 12 for this, as you can see, the 12 is over there its kind of hard to read. So you can count up 8, 9, 10, 11, 12.

and im going to take my led over here and look for the longer pin, as you can see, on the right side of the led. You have the longer pin, and this means that this is the positive pin and by being positive, you want to insert the positive pin into your desired digital pin. So, as you can see, the right one is my positive pin, which is longer im just going to insert it into the 12th slot. 8. 9. 10. 11. 12.. Just put it right in as far as it can go, dont apply too much pressure, though let me show you a side view. It looks just like this now were going to attach our resistor the negative side, which is the shorter side, so you dont need to do much just tie it around just make sure it is connected, and you insert the resistor into the ground pen, as you can See its right there, its after the 13th slot, as you can see right over there heres a closer view just going to insert it into the ground, pin just like that. Now it looks a little weird right now. So let me just clean it up a little and just like that. Our led is connected with the resistor there to make sure that our led doesnt glow now lets connect it back into the computer and, as you can see, our arduino is now on now lets. Go back into our pictoblock software and connect our arduino again com tree just like that.

Its connected and now lets code it in this video im going to be using stage mode, as i will be, showing you how to use upload mode in another video so lets. First, go to events and choose the flag select event, as this will start our arduino program when the flag is clicked, be sure to upload your firmware too. Now, when the flag is clicked, we want the led to turn on for a bit turn off and then turn on for longer time to imitate a dot and a dash in morse code. So lets choose a forever loop to make sure that it keeps repeating our code lets go to the arduino uno section. We are going to be using the set digital pin block. As i showed you earlier, we connected our led into a digital pin, so this block controls the digital pin. So we use digital pin 12. So lets quickly choose that right there and lets choose the output as low low means that it will not send an electrical signal to that. Pin and high means that it will so lets set it as that to make sure that our led starts off as off. Now lets add a wait, wait one second and then were going to turn the digital pin on for 0.5 seconds, so digital pin 12 and set it to high, which means that our led will turn on lets go back and we will wait 0.

5 seconds there. We go and that will imitate a dot and after 0.5 seconds our led will turn off again, so it will turn on wait. 0.5 seconds, then turn off choose 12 low. Now i can just duplicate this, and now we want to imitate a dash, so our dot is done. Lets make it imitate a dash, so lets wait 0.5 seconds and then turn it on again and this time were going to be waiting one whole. Second, as it is longer than 0.5 seconds, it will look like a dash there. We go one second and then after one second, we will turn it off again and then we will wait one second again now that is our core. According to your name, you can look on google and find the morse code for the beginning of your name and now lets click our flag and see what the arduino does. Did you see that the arduino keeps blinking the morse code of a? Let me show you that again dot dash now this might seem like a very simple project to you, but the arduino uno can do much much more. You can make simple projects such as this, which just blinks an led or you can go all the way up to remote, controlled cars or even robotic arms. Let me turn off the light to help you see better now before we end the video. I have a challenge for you. I challenge you to code, the arduino so that you can write a full sentence and then the arduino will blink it out for you lets see if you can do it.

If you manage to do it, please send a link in the comments if you enjoyed this video be sure to subscribe and like you can also share this with other people who are interested in starting with arduino.

https://www.youtube.com/watch?v=znhS3Ba06c0