Mercurial > d1workshop
changeset 6:b263b8040dc0
Reorganize
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Thu, 09 Jun 2016 13:45:15 +0200 |
| parents | 0161e1861f1b |
| children | 53ba8183ea30 |
| files | basics.rst blink.rst board.rst connecting.rst external.rst index.rst prerequisites.rst pwm.rst servo.rst setup.rst |
| diffstat | 10 files changed, 355 insertions(+), 343 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/basics.rst Thu Jun 09 13:45:15 2016 +0200 @@ -0,0 +1,230 @@ +Basics +****** + +Blink +===== + +The traditional first program for hobby electronics is a blinking light. We +will try to build that. + +The boards you have actually have a light built-in, so we can use that. There +is a LED (light-emitting diode) near the antenna (the golden zig-zag). The plus +side of that LED is connected to the ``3v3`` pins internally, and the minus +side is connected to ``gpio2``. So we should be able to make that LED shine +with our program by making ``gpio2`` behave like the gnd pins. We need to +"bring the ``gpio2`` low", or in other words, make it connected to ``gnd``. +Let's try that:: + + from machine import Pin + + led = Pin(2, Pin.OUT) + led.low() + +The first line "imports" the "Pin" function from the "machine" module. In +Python, to use any libraries, you first have to import them. The "machine" +module contains most of the hardware-specific functions in Micropython. + +Once we have the "Pin" function imported, we use it to create a pin object, +with the first parameter telling it to use ``gpio2``, and the second parameter +telling it to switch it into output mode. Once created, the pin is assigned to +the variable we called "led". + +Finally, we bring the pin low, by calling the "low" method on the "led" +variable. At this point the LED should start shining. In fact, it may have +started shining a line earlier, because once we switched the pin into output +mode, its default state is "low". + +Now, how to make the LED stop shining? There are two ways. We could switch it +back into "input" mode, where the pin is not connected to anything. Or we could +bring it "high". If we do that, both ends of the LED will be connected to +"plus", and the current won't flow. We do that with:: + + led.high() + +Now, how can we make the LED blink 10 times? We could of course type +``led.low()`` and ``led.high()`` ten times quickly, but that's a lot of work +and we have computers to do that for us. We can repeat a command or a set of +commands using the "for" loop:: + + for i in range(10): + led.high() + led.low() + +Note, that when you are typing this, it will look more like:: + + >>> for i in range(10): + ... led.high() + ... led.low() + ... + ... + >>> + +That's because the console automatically understands that when you indent a +line, you mean it to be a block of code inside the "for" loop. You have to +un-indent the last line (by removing the spaces with backspace) to finish this +command. + +What happened? Nothing interesting, the LED just shines like it did. That's +because the program blinked that LED as fast as it could -- so fast, that we +didn't even see it. We need to make it wait a little before the blinks, and for +that we are going to use the "time" module. First we need to import it:: + + import time + +And then we will repeat our program, but with the waiting included:: + + for i in range(10): + led.high() + time.sleep(0.5) + led.low() + time.sleep(0.5) + +Now the LED should turn on and off every half second. + + +External Components +=================== + +Now let's try the same, but not with the build-in LED -- let's connect an +external LED and try to use that. The connection should look like this: + +.. image:: ./images/blink.png + :width: 512px + +Note how one leg of the LED is a little bit longer, and the other had a +flattening on the plastic of the LED next to it. The long leg should go to the +plus, and the short one to the minus. We are connecting the LED in opposite way +than the internal one is connected -- between the pin and ``gnd``. That means +that it will shine when the pin is high, and be dark when it's low. + +Also note how we added a resistor in there. That is necessary to limit the +amount of current that is going to flow through the LED, and with it, its +brightness. Without the resistor, the LED would shine very bright for a short +moment, until either it, or the board, would overheat and break. We don't want +that. + +Now, let's try the code:: + + from machine import Pin + import time + + led = Pin(14, Pin.OUT) + for i in range(10): + led.high() + time.sleep_ms(500) + led.low() + time.sleep_ms(500) + +Again, you should see the LED blink 10 times, half a second for each blink. + +This time we used ``time.sleep_ms()`` instead of ``time.sleep()`` -- it does +the same thing, but takes the number of milliseconds instead od seconds as the +parameter, so we don't have to use fractions. + + +Pulse Width Modulation +====================== + +Wouldn't it be neat if instead of blinking, the LED slowly became brighter and +then fade out again? Can we do this somehow? + +The brightness of the LED depends on the voltage being supplied to it. +Unfortunately, our GPIO pins only have a simple switch functionality -- we +can turn them on or off, but we can't fluently change the voltage (there are +pins that could do that, called DAC, for "digital to analog converter", but +our board doesn't have those). But there is another way. Remember when we +first tried to blink the LED without any delay, and it happened too fast to +see? + +Turns out we can blink the LED very fast, and by varying the time it is on and +off change how bright it seems to be to the human eye. The longer it is on and +the shorter it is off, the brighter it will seem. + +Now, we could do that with a simple loop and some very small delays, but it +would keep our board busy and prevent it from doing anything else, and also +wouldn't be very accurate or terribly fast. But the ESP8266 has special +hardware dedicated just for blinking, and we can use that! This hardware is +called PWM (for Pulse Width Modulation), and you can use it like this:: + + from machine import Pin, PWM + import time + + pwm = PWM(Pin(2)) + pwm.duty(896) + time.sleep(1) + pwm.duty(512) + time.sleep(1) + pwm.duty(0) + +If you run this, you should see the blue led on ``gpio2`` change brightness. +The possible range is from 1023 (100% duty cycle, the LED is off) to 0 (0% +duty cycle, the LED is on full brightness). Why is 0 full brightness? Remember, +that the LED on the ``gpio2`` is reversed -- it shines when the pin is off, +and the duty cycle tells how much the pin is on. + +You can also change the frequency of the blinking. Try this:: + + pwm.freq(1) + +That should blink the LED with frequency of 1Hz, so once per second -- we are +basically back to our initial program, except the LED blinks "in the +background" controlled by dedicated hardware, while your program can do other +things! + + +Servomechanisms +=============== + +Time to actually physically move something. If you plan on building a robot, +there are three main ways of moving things from the microcontroller: + + * a servomechanism (servo for short), + * an H-bridge and a DC motor, + * a stepper or brushless motor with a driver. + +We are going to focus on the servo first, because I think this is the easiest +and cheapest way. We are going to use a cheap "hobby" servo, the kind that is +used in toys -- it's not particularly strong, but it's enough for most use +cases. + +.. warning:: + Don't try to force the movement of the servo arms with your hand, you are + risking breaking the delicate plastic gears inside. + +A hobby servo has three wires: brown or black ``gnd``, red or orange ``vcc``, +and white or yellow ``signal``. The ``gnd`` should of course be connected to +the ``gnd`` of our board. The ``vcc`` is the power source for the servo, and +we are going to connect it to the ``vin`` pin of our board -- this way it is +connected directly to the USB port, and not powered through the board. + +.. image:: ./images/servo.png + +.. caution:: + Servos and motors usually require a lot of current, more then your board + can supply, and often even more than than you can get from USB. Don't + connect them to the ``3v3`` pins of your board, and if you need two or + more, power them from a battery (preferably rechargeable). + +The third wire, ``signal`` tells the servo what position it should move to, +using a 50Hz PWM signal. The center is at around 77, and the exact range varies +with the servo model, but should be somewhere between 30 and 122, which +corresponds to about 180° of movement. Note that if you send the servo a signal +that is outside of the range, it will still obediently try to move there -- +hitting a mechanical stop and buzzing loudly. If you leave it like this for +longer, you can damage your servo, your board or your battery, so please be +careful. + +So now we are ready to try and move it to the center position:: + + from machine import Pin, PWM + servo = PWM(Pin(14), freq=50, duty=77) + +Then we can see where the limits of its movement are:: + + servo.duty(30) + servo.duty(122) + +There also exist "continuous rotation" servos, which don't move to the +specified position, but instead rotate with specified speed. Those are suitable +for building simple wheeled robots. It's possible to modify a normal servo into +a continuous rotation servo.
--- a/blink.rst Thu Jun 09 12:51:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -Blink -***** - -The traditional first program for hobby electronics is a blinking light. We -will try to build that. - -The boards you have actually have a light built-in, so we can use that. There -is a LED (light-emitting diode) near the antenna (the golden zig-zag). The plus -side of that LED is connected to the ``3v3`` pins internally, and the minus -side is connected to ``gpio2``. So we should be able to make that LED shine -with our program by making ``gpio2`` behave like the gnd pins. We need to -"bring the ``gpio2`` low", or in other words, make it connected to ``gnd``. -Let's try that:: - - from machine import Pin - - led = Pin(2, Pin.OUT) - led.low() - -The first line "imports" the "Pin" function from the "machine" module. In -Python, to use any libraries, you first have to import them. The "machine" -module contains most of the hardware-specific functions in Micropython. - -Once we have the "Pin" function imported, we use it to create a pin object, -with the first parameter telling it to use ``gpio2``, and the second parameter -telling it to switch it into output mode. Once created, the pin is assigned to -the variable we called "led". - -Finally, we bring the pin low, by calling the "low" method on the "led" -variable. At this point the LED should start shining. In fact, it may have -started shining a line earlier, because once we switched the pin into output -mode, its default state is "low". - -Now, how to make the LED stop shining? There are two ways. We could switch it -back into "input" mode, where the pin is not connected to anything. Or we could -bring it "high". If we do that, both ends of the LED will be connected to -"plus", and the current won't flow. We do that with:: - - led.high() - -Now, how can we make the LED blink 10 times? We could of course type -``led.low()`` and ``led.high()`` ten times quickly, but that's a lot of work -and we have computers to do that for us. We can repeat a command or a set of -commands using the "for" loop:: - - for i in range(10): - led.high() - led.low() - -Note, that when you are typing this, it will look more like:: - - >>> for i in range(10): - ... led.high() - ... led.low() - ... - ... - >>> - -That's because the console automatically understands that when you indent a -line, you mean it to be a block of code inside the "for" loop. You have to -un-indent the last line (by removing the spaces with backspace) to finish this -command. - -What happened? Nothing interesting, the LED just shines like it did. That's -because the program blinked that LED as fast as it could -- so fast, that we -didn't even see it. We need to make it wait a little before the blinks, and for -that we are going to use the "time" module. First we need to import it:: - - import time - -And then we will repeat our program, but with the waiting included:: - - for i in range(10): - led.high() - time.sleep(0.5) - led.low() - time.sleep(0.5) - -Now the LED should turn on and off every half second.
--- a/board.rst Thu Jun 09 12:51:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -Development Board -***************** - -The board we are using is called "NodeMCU AMICA" and has an ESP8266 module -on it, which we will be programming. It comes with the latest version of -Micropython already setup on it, together with all the drivers we are going -to use. - -.. note:: - The D0, D1, D2, ... numbers printed on the board are different from what - Micropython uses -- because originally those boards were made for a - different software. Make sure to refer to the image below to determine - which pins are which. - -.. image:: ./images/board.png - :width: 512px - - -On top it has a micro-USB socket, for connecting to the computer. Next to it -are two buttons, one for reset and one for flashing. Then on both sides of the -board are two rows of pins, to which we will be connecting cables. - -The symbols meaning is as follows: - - * ``3v3`` - this is a fancy way to write 3.3V, which is the voltage that the - board runs on internally. You can think about this pin like the plus side - of a battery. There are several pins like this, they are all connected - inside. - * ``gnd`` - this is the ground. Think about it like the minus side of the - battery. They are also all connected. - * ``gpioXX`` - "gpio" stands for "general purpose input output". Those are - the pins we will be using for sending and receiving signals to and from - various devices that we will connect to them. They can act as output -- - pretty much like a switch that you can connect to plus or to minus with - your program. Or they can act as input, telling your program whether they - are connected to plus or minus. - * ``a0`` - this is the analog pin. It can measure the voltage that is applied - to it, but it can only handle up to 1V. - * ``vin`` - this pin is connected with the 5V from your computer. You can - also use it to power your board with a battery when it's not connected to - the computer. The voltage applied here will be internally converted to the - 3.3V that the board needs. - * ``rst`` - this is a reset button (and a corresponding pin, to which you can - connect external button). - * ``flash`` - hold down this button while resetting to bring the board into - programming mode (also known as flashing mode). - -The other pins are used internally by the board, and we will not be connecting -anything to them. -
--- a/connecting.rst Thu Jun 09 12:51:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -Connecting -********** - -The board you got should already have Micropython with all the needed libraries -flashed on it. In order to access its console, you will need to connect it to -your computer with the micro-USB cable, and access the serial interface that -appears with a terminal program. - -Linux and MacOS -=============== - -Simply open a terminal and run the following command:: - - screen /dev/ttyUSB0 115200 - -Windows -======= - -For the serial interface to appear in your system, you will need to install the drivers_ for CP2102. Once you have that, you can use either Hyper Terminal or PuTTy to connect to it, following this guide_. - -The parameters for the connection are: 115200 baud rate, 8 data bits, no parity, 1 stop bit, no flow control. - -Hello world! -============ - -Once you are connected, press "enter" and you should see the Micropython prompt, that looks like this:: - - >>> - -It's traditional to start with a "Hello world!" program, so type this and press "enter":: - - print("Hello world!") - -If you see "Hello world!" displayed in the next line, then congratulations, you got it working. - -.. _drivers: http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx -.. _guide: https://techawarey.wordpress.com/tag/serial-port-communication-in-windows-7-using-hyper-terminal-and-putty/
--- a/external.rst Thu Jun 09 12:51:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -External Components -******************* - -Now let's try the same, but not with the build-in LED -- let's connect an -external LED and try to use that. The connection should look like this: - -.. image:: ./images/blink.png - :width: 512px - -Note how one leg of the LED is a little bit longer, and the other had a -flattening on the plastic of the LED next to it. The long leg should go to the -plus, and the short one to the minus. We are connecting the LED in opposite way -than the internal one is connected -- between the pin and ``gnd``. That means -that it will shine when the pin is high, and be dark when it's low. - -Also note how we added a resistor in there. That is necessary to limit the -amount of current that is going to flow through the LED, and with it, its -brightness. Without the resistor, the LED would shine very bright for a short -moment, until either it, or the board, would overheat and break. We don't want -that. - -Now, let's try the code:: - - from machine import Pin - import time - - led = Pin(14, Pin.OUT) - for i in range(10): - led.high() - time.sleep_ms(500) - led.low() - time.sleep_ms(500) - -Again, you should see the LED blink 10 times, half a second for each blink. - -This time we used ``time.sleep_ms()`` instead of ``time.sleep()`` -- it does -the same thing, but takes the number of milliseconds instead od seconds as the -parameter, so we don't have to use fractions.
--- a/index.rst Thu Jun 09 12:51:10 2016 +0200 +++ b/index.rst Thu Jun 09 13:45:15 2016 +0200 @@ -11,13 +11,8 @@ .. toctree:: :maxdepth: 2 - prerequisites.rst - board.rst - connecting.rst - blink.rst - external.rst - pwm.rst - servo.rst + setup.rst + basics.rst Indices and tables
--- a/prerequisites.rst Thu Jun 09 12:51:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -Prerequisites -************* - -To participate in the workshop, you will need the following: - - * A laptop with Linux, Mac OS or Windows and at least one free USB port. - * If it's Windows or Mac OS, make sure to install `drivers`_ for the CP2102 UBS2TTL chip. MacOS El Capitan requires `disabling kext signing`_ to install it. - * A micro-USB cable with data lines that fits your USB port. - * You will need a terminal application installed. For Linux and Mac you can - use ``screen``, which is installed by default. For Windows we recommend `PuTTy`_ - * Please note that the workshop will be in English. - -.. _drivers: http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx -.. _disabling kext signing: http://farazmemon.com/2016/02/07/flashing-latest-firmware-on-nodemcu-devkit-v0-9-osx-el-capitan/ -.. _PuTTy: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html - -In addition, at the workshop, you will receive: - * "NodeMCU AMICA" development board with ESP8266 on it, - * Red LED, - * 100Ω resistor, - * SG90 microservo, - * Female-female and Male-female dupont cables, - * Piezoelectric speaker. - -You will take all that home with you. - -There will be also some additional hardware available for experimenting, -which you won't take home.
--- a/pwm.rst Thu Jun 09 12:51:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -Pulse Width Modulation -********************** - -Wouldn't it be neat if instead of blinking, the LED slowly became brighter and -then fade out again? Can we do this somehow? - -The brightness of the LED depends on the voltage being supplied to it. -Unfortunately, our GPIO pins only have a simple switch functionality -- we -can turn them on or off, but we can't fluently change the voltage (there are -pins that could do that, called DAC, for "digital to analog converter", but -our board doesn't have those). But there is another way. Remember when we -first tried to blink the LED without any delay, and it happened too fast to -see? - -Turns out we can blink the LED very fast, and by varying the time it is on and -off change how bright it seems to be to the human eye. The longer it is on and -the shorter it is off, the brighter it will seem. - -Now, we could do that with a simple loop and some very small delays, but it -would keep our board busy and prevent it from doing anything else, and also -wouldn't be very accurate or terribly fast. But the ESP8266 has special -hardware dedicated just for blinking, and we can use that! This hardware is -called PWM (for Pulse Width Modulation), and you can use it like this:: - - from machine import Pin, PWM - import time - - pwm = PWM(Pin(2)) - pwm.duty(896) - time.sleep(1) - pwm.duty(512) - time.sleep(1) - pwm.duty(0) - -If you run this, you should see the blue led on ``gpio2`` change brightness. -The possible range is from 1023 (100% duty cycle, the LED is off) to 0 (0% -duty cycle, the LED is on full brightness). Why is 0 full brightness? Remember, -that the LED on the ``gpio2`` is reversed -- it shines when the pin is off, -and the duty cycle tells how much the pin is on. - -You can also change the frequency of the blinking. Try this:: - - pwm.freq(1) - -That should blink the LED with frequency of 1Hz, so once per second -- we are -basically back to our initial program, except the LED blinks "in the -background" controlled by dedicated hardware, while your program can do other -things!
--- a/servo.rst Thu Jun 09 12:51:10 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -Servomechanisms -*************** - -Time to actually physically move something. If you plan on building a robot, -there are three main ways of moving things from the microcontroller: - - * a servomechanism (servo for short), - * an H-bridge and a DC motor, - * a stepper or brushless motor with a driver. - -We are going to focus on the servo first, because I think this is the easiest -and cheapest way. We are going to use a cheap "hobby" servo, the kind that is -used in toys -- it's not particularly strong, but it's enough for most use -cases. - -.. warning:: - Don't try to force the movement of the servo arms with your hand, you are - risking breaking the delicate plastic gears inside. - -A hobby servo has three wires: brown or black ``gnd``, red or orange ``vcc``, -and white or yellow ``signal``. The ``gnd`` should of course be connected to -the ``gnd`` of our board. The ``vcc`` is the power source for the servo, and -we are going to connect it to the ``vin`` pin of our board -- this way it is -connected directly to the USB port, and not powered through the board. - -.. image:: ./images/servo.png - -.. caution:: - Servos and motors usually require a lot of current, more then your board - can supply, and often even more than than you can get from USB. Don't - connect them to the ``3v3`` pins of your board, and if you need two or - more, power them from a battery (preferably rechargeable). - -The third wire, ``signal`` tells the servo what position it should move to, -using a 50Hz PWM signal. The center is at around 77, and the exact range varies -with the servo model, but should be somewhere between 30 and 122, which -corresponds to about 180° of movement. Note that if you send the servo a signal -that is outside of the range, it will still obediently try to move there -- -hitting a mechanical stop and buzzing loudly. If you leave it like this for -longer, you can damage your servo, your board or your battery, so please be -careful. - -So now we are ready to try and move it to the center position:: - - from machine import Pin, PWM - servo = PWM(Pin(14), freq=50, duty=77) - -Then we can see where the limits of its movement are:: - - servo.duty(30) - servo.duty(122) - -There also exist "continuous rotation" servos, which don't move to the -specified position, but instead rotate with specified speed. Those are suitable -for building simple wheeled robots. It's possible to modify a normal servo into -a continuous rotation servo.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/setup.rst Thu Jun 09 13:45:15 2016 +0200 @@ -0,0 +1,123 @@ +Setup +***** + +Prerequisites +============= + +To participate in the workshop, you will need the following: + + * A laptop with Linux, Mac OS or Windows and at least one free USB port. + * If it's Windows or Mac OS, make sure to install `drivers`_ for the CP2102 UBS2TTL chip. MacOS El Capitan requires `disabling kext signing`_ to install it. + * A micro-USB cable with data lines that fits your USB port. + * You will need a terminal application installed. For Linux and Mac you can + use ``screen``, which is installed by default. For Windows we recommend `PuTTy`_ + * Please note that the workshop will be in English. + +.. _drivers: http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx +.. _disabling kext signing: http://farazmemon.com/2016/02/07/flashing-latest-firmware-on-nodemcu-devkit-v0-9-osx-el-capitan/ +.. _PuTTy: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html + +In addition, at the workshop, you will receive: + * "NodeMCU AMICA" development board with ESP8266 on it, + * Red LED, + * 100Ω resistor, + * SG90 microservo, + * Female-female and Male-female dupont cables, + * Piezoelectric speaker. + +You will take all that home with you. + +There will be also some additional hardware available for experimenting, +which you won't take home. + + +Development Board +================= + +The board we are using is called "NodeMCU AMICA" and has an ESP8266 module +on it, which we will be programming. It comes with the latest version of +Micropython already setup on it, together with all the drivers we are going +to use. + +.. note:: + The D0, D1, D2, ... numbers printed on the board are different from what + Micropython uses -- because originally those boards were made for a + different software. Make sure to refer to the image below to determine + which pins are which. + +.. image:: ./images/board.png + :width: 512px + + +On top it has a micro-USB socket, for connecting to the computer. Next to it +are two buttons, one for reset and one for flashing. Then on both sides of the +board are two rows of pins, to which we will be connecting cables. + +The symbols meaning is as follows: + + * ``3v3`` - this is a fancy way to write 3.3V, which is the voltage that the + board runs on internally. You can think about this pin like the plus side + of a battery. There are several pins like this, they are all connected + inside. + * ``gnd`` - this is the ground. Think about it like the minus side of the + battery. They are also all connected. + * ``gpioXX`` - "gpio" stands for "general purpose input output". Those are + the pins we will be using for sending and receiving signals to and from + various devices that we will connect to them. They can act as output -- + pretty much like a switch that you can connect to plus or to minus with + your program. Or they can act as input, telling your program whether they + are connected to plus or minus. + * ``a0`` - this is the analog pin. It can measure the voltage that is applied + to it, but it can only handle up to 1V. + * ``vin`` - this pin is connected with the 5V from your computer. You can + also use it to power your board with a battery when it's not connected to + the computer. The voltage applied here will be internally converted to the + 3.3V that the board needs. + * ``rst`` - this is a reset button (and a corresponding pin, to which you can + connect external button). + * ``flash`` - hold down this button while resetting to bring the board into + programming mode (also known as flashing mode). + +The other pins are used internally by the board, and we will not be connecting +anything to them. + + +Connecting +========== + +The board you got should already have Micropython with all the needed libraries +flashed on it. In order to access its console, you will need to connect it to +your computer with the micro-USB cable, and access the serial interface that +appears with a terminal program. + + +Linux and MacOS +--------------- + +Simply open a terminal and run the following command:: + + screen /dev/ttyUSB0 115200 + + +Windows +------- + +For the serial interface to appear in your system, you will need to install the drivers_ for CP2102. Once you have that, you can use either Hyper Terminal or PuTTy to connect to it, following this guide_. + +The parameters for the connection are: 115200 baud rate, 8 data bits, no parity, 1 stop bit, no flow control. + + +Hello world! +------------ + +Once you are connected, press "enter" and you should see the Micropython prompt, that looks like this:: + + >>> + +It's traditional to start with a "Hello world!" program, so type this and press "enter":: + + print("Hello world!") + +If you see "Hello world!" displayed in the next line, then congratulations, you got it working. + +.. _guide: https://techawarey.wordpress.com/tag/serial-port-communication-in-windows-7-using-hyper-terminal-and-putty/
