woensdag 19 maart 2014

The Arduino arrived!

Today I received the Arduino Ethernet, the Arduino Proto shield, the USB to serial device, and the Temperature sensor.

Running your first program is very easy:

  1. Install the Arduino IDE software on your computer (I used the latest windows version 1.0.5-r2)
  2. Plug the USB to serial device into the Arduino and connect the other end of the USB cable to the computer.

  3. After the USB driver was installed, I had to unplug the Arduino and plug it in once again to get it to work.

  4. Launch the Arduino IDE
  5. In the menu, select Tools | Board | Arduino Uno
  6. In the menu, select Tools | Serial Port | <the right COM port>
  7. Open an example program, I took "C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino"
  8. Click the Upload button to compile the program, transfer it to the Arduino, and start it.
  9. Nothing happened in my case, because the Arduino Ethernet does not have an onboard LED on pin 13.
  10. I added some debug statements to the original example program that sends some text back to the IDE using the USB connection to verify its execution (highlighted in blue)

  11. #include <SoftwareSerial.h>

      Turns on an LED on for one second, then off for one second, repeatedly.
      This example code is in the public domain.
    // Pin 13 has an LED connected on most Arduino boards.
    // give it a name:
    int led = 13;

    // the setup routine runs once when you press reset:
    void setup() {                
      // initialize the digital pin as an output.
      pinMode(led, OUTPUT);    
      Serial.begin(9600);           // set up Serial library at 9600 bps 
      Serial.println("Hello world!");

    // the loop routine runs over and over again forever:
    void loop() {
      digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
      Serial.println("LED on");
      delay(1000);               // wait for a second
      digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
      Serial.println("LED off");
      delay(1000);               // wait for a second

  12. In the IDE select "Tools | Serial Monitor" to start monitoring your application

  13. Having the LED blink was more fun, so I got the electronics kit I had lying around and hooked up a LED and a resistor to pin 13 and GND.

Geen opmerkingen:

Een reactie posten