Series:
Hi,
After the post of introduction today I start to create the app for example with Arduino. For this I have used the following hardware
- Arduino one Rev 3, €20
- Groove Starter Kit, $29 + shipping
The Arduino one Rev 3 is one of the most popular, and Groove kit, allows us to connect the sensors and actors to the plate in an easy way without having to deal with wires in craft.
As well with the hardware complete, the following is working with development tools. This is simpler:
- Arduino 1.0.5 for windows (http://arduino.cc/en/Main/Software). The official Arduino IDE along with the driver for the USB port
- Visual Micro (http://www.visualmicro.com/), a must have: an extension for Visual Studio 2012 to create our projects directly in our favorite IDE.
The next step is to assemble the hardware, very simple step:
- Connect LED to pin 6
- Connect the BUTTON to pin 9
And we are going to create the application.
1. In Visual Studio 2012 created a new Arduino project
2. Once the project is created, select the board Arduino Uno with the menu “Tools / / Arduino / / Boards / / Arduino Uno”. From the same menu we select the COM port to connect our Arduino.
If you do not know to which port is connected to your arduino, this post can help you.
3 Add the application code
1: const int buttonPin = 8; // the number of the pushbutton pin
2: const int ledPin = 6; // the number of the LED pin
3: int buttonState = 0; // variable for reading the pushbutton status
4: bool ledState = false;
5:
6: void setup()
7: {
8: pinMode(buttonPin, INPUT);
9: pinMode(ledPin, OUTPUT);
10: }
11:
12: void loop()
13: {
14: buttonState = digitalRead(buttonPin);
15: if (buttonState == HIGH)
16: {
17: ledState = !ledState;
18: delay(500);
19: }
20: if(ledState)
21: {
22: digitalWrite(ledPin, HIGH); // LED ON
23: }
24: else
25: {
26: digitalWrite(ledPin, LOW); // LED OFF
27: }
28: }
4. The code is quite simple, only I must highlight the following
-Then check the status of the Button (line 15) change the State of a flag by true or false and apply a delay from 500 to some reaction on the plate. If you do not add this delay click executes as many times as the loop pass by that function. There are more elegant ways of doing this, it is
5 I display the application (F5!) In the output panel will see a message similar to the following (amazing app 1 Kb!)
Compiling ‘ Xduino02′ for ‘Arduino Uno’
Binary sketch size: 1274 bytes (4% of to 32256 byte maximum) (0.23 secs)
Uploading to I/O board using ‘ COM3′
Done uploading
6. My application is running (I leave the video that perhaps will become viral)
And ready, in 28 lines of code I have my application running. In the next post, we will see if we do the same with Netduino or .net Gadgeteer.
Saludos @ Home
El Bruno
![]() |
![]() |
![]() |
1 comment