Hey All,
I decided to make an alternate write up to the NodeJS blink tutorial (which is awesome BTW), because if you're like me, a noob coming over from the Arduino world, you want a quick and easy explanation of how to get started using Arduino IDE (or similar, using Arduino's flavor of Java).
Notes and warnings:
**This isn't as easy as the Arduino board, because the Breakout Board doesn't have any level shifters. ***You have to be super careful so you don't fry the Edison by accidentally over-volting the GPIO. You also need extra components to translate the 1.8V output into something that can actually power an LED, like 3.3V. Sparkfun has level shifter breakout boards that are super easy to work with, but since we're only dealing with OUTPUT, we can get away with the affordable 2N3904 NPN transistor (We'll be using it as a "relay/switch"). If you're not comfortable making your own Level Shifter circuit, snag Sparkfun's level shifter break out board now. You'll need it later if you want to get INPUTs from common 3.3V or 5V sensors and such. Get it here.
What you'll need:
-Intel Edison Breakout board - With header pins soldered on the breakout board (tutorial link at bottom)
-Arduino-Intel IDE installed
-A breadboard
-An LED
-1k ohm Resistor
-2N3904 NPN Transistor (general purpose)
-Male to Female jumper wires
-Male to Male jumper wires (optional, but makes layout easier)
-1N4007 Diode (optional, as a safety check)
The next steps assume you've already followed the getting started guide, Installed all drivers and the Arduino-Intel IDE, and updated your Edison to the latest/greatest image.
1.Connect your Edison to your PC
Note: You'll need to plug in both Micro-B USB ports, one for power, and the other for the virtual COM port.
*When Setting up Arduino IDE for the first time, don't use the same COM port which you used for Putty.
In Device Manager (on Windows) use "Intel Edison Virtual COM Port (#)" to upload sketches, and check Serial Monitor's outputs. For me COM7 is used for Putty, and COM6 is used for Arduino IDE.
2.Assemble components on the breadboard.
Note: We use the 2N3904 NPN transistor, because the relatively low voltage (1.8V) of the Edison GPIO's is enough to activate the circuit through its Base (B), so current flows from the Collector (C) to the Emitter (E), and the LED turns on using 3.3V. This is how relays/switches work. Hooray!
Edison PINOUT Hookup:
-Power 3.3V (Red) from J20-P02
-GND (Black) from J19-P03
-OUTPUT (Blue) from J18-P13
2N3904 NPN Transistor hookup (the flat side is facing us):
-3.3V into the 2N3904's Collector (C) - through the 1K ohm Resistor and LED (the long leg is +)
-OUTPUT (through the diode) into 2N3904's Base (B)
-GND into 2N3904's Emitter (E)
1N4007 Diode:
Notice how the white line is on the side going toward the Base (B) of our transistor.
This is totally optional but recommended, because it protects against reverse polarity, and if we were to accidentally send 3.3V into the GPIO, we may damage the Edison's 1.8V logic. If you have the diode reversed, your LED will not blink. Sad face.
3.Code in Arduino IDE.
Note: You'll want to eventually map out the Edison's GPIO's into their corresponding Arduino IDE pin numbers (check links at the bottom of this page), but for right now we'll just focus on D0 (or J18-P13 on the breakout board)
void setup() { //Digital Pin 0 in Arduino IDE is mapped to J18-P13 on the Edison breakout board pinMode(0, OUTPUT); } void loop() { //Tun on the LED digitalWrite(0,HIGH); delay(1000); //Turn off the LED digitalWrite(0,LOW); delay(1000); }
4.Upload your sketch.
You should see a blinking LED.
Resources:
Soldering header pins on to the breakout board (This is a really good resource for getting started with the breakout board)
GPIO Mapping from Arduino IDE to Edison breakout board -Tip: in the linked PDF found in the 2nd post on that thread, the Edison GP pin is on the left, and its corresponding Arduino pin is on the right, you then find which GP pin is mapped to which physical pin out on the Breakout board (see hardware guide below)
ex. Arduino D0 = Edison GP130 = Breakout Board J18-P13
Trouble shooting Arduino IDE and the breakout board (special thanks to KurtE and mikalHart - This covers correct COM Port assignment)
Hardware guides:
This is a WIP, so feel free to point out corrections or clarifications, where needed.
I hope this helps you out, and good luck!
Cheers,
Andy