Difference between revisions of "Implementing Arduino using Generic Serial Device"

From LinuxMCE
Jump to: navigation, search
(Arduino Uno - 1004 Setup)
m (Arduino moved to Implementing Arduino using Generic Serial Device: Better description)
(No difference)

Revision as of 19:39, 3 September 2012

Version Status Date Updated Updated By
710 Unknown N/A N/A
810 Unknown N/A N/A
1004 Working 3th September 2012 Daballiem0
1204 Unknown N/A N/A
1404 Unknown N/A N/A
Usage Information

General Info

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is programmed using the Arduino programming language (based on Wiring) and the Arduino development environment (based on Processing). Arduino projects can be stand-alone or they can communicate with software running on a computer (e.g. Flash, Processing, MaxMSP).

Arduino uno test.jpg

Arduino Uno - 1004 Setup

Prepare the Arduino Uno;

Shopping list:

Arduino Uno Ethernet Shield IDE installed on computer

Sketch to upload to Arduino;

/*
 * Arduino LMCE interlink
 *
 * A basic example displaying the ability of LinuxMCE
 * to control an LED on an Arduino with
 * an ethernet shield.
 * 
 * Daballiemo
 * http://linuxmce.org
 */
#include <SPI.h>
#include <Ethernet.h>
int switchPin = 2;
int LEDpin = 5;						//LED set to pin 5
int x;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };		//must give WIZnet a MAC
byte ip[] = { 192, 168, 80, 129 };				//must configure WIZnet IP
EthernetServer server = EthernetServer(69);			//TCP port the server is listening on, I'm using port 69, but you could use any
void setup()
{
 Ethernet.begin(mac, ip);
 server.begin();
 Serial.begin(9600);						//for troubleshooting purposes (not needed)
 pinMode(LEDpin, OUTPUT);
 pinMode(switchPin, INPUT);                                    // sets the digital pin as input to read switch
}
void loop () {
EthernetClient client = server.available();			//client connects to server
if (client){							//if connection present
 x = client.read();						//read information coming from server
 Serial.println(x);}						//print to serial (troublshooting only)
if (x == 49){							//if information sent is a zero
 digitalWrite(LEDpin, LOW);}					//turn of LED
else if (x == 48){						//if information sent is a one
 digitalWrite(LEDpin, HIGH);}				        //turn on LED
else if (x == 2){						//if information sent is a two
 digitalWrite(LEDpin, HIGH);					//blink the LED
 delay(500);
 digitalWrite(LEDpin, LOW);
 delay(500);}
if (digitalRead(switchPin) == 1){
 Serial.println("Button has been pressed " );
 server.write("Button has been pressed ");}                    // Read the pin and display the value
}



Prepare the LMCE Enviroment;

Setting up the Arduino to be controlled through GSD