Hardware Reference
In-Depth Information
Engage Thrusters
We will warm up by implemening the LED example on Spark Core or something similar.
The documentaion includes code to connect an LED wi th a resistor to the Core
( htt p://docs.spark.io/examples/ ). We decided to do something even simpler.
There is already an LED connected to pin D7 and we decided to turn this one on instead.
All the apps you need can be downloaded to a custom web page available for each Spark
Core through a username and password.
Once you have set up the Core, you will create a username and password. For different
Cores, you will need different usernames. Using this, you can go to the Spark home page
( http://www.spark.io/ ) and click on the Build buton. This takes you to the home
page of the development environment.
Using this development environment, we created a simple LED blinking applicaion:
void setup() {
pinMode(7,OUTPUT);
}
void loop() {
// turn the LED on (HIGH is the voltage level)
digitalWrite(7, HIGH);
// wait for a second
delay(1000);
// turn the LED off by making the voltage LOW
digitalWrite(7, LOW);
// wait for a second
delay(1000);
}
The preceding code is writen in C programming language. If you are jumping
directly to this project from other projects, we suggest that you familiarize
yourself with the Arduino or Spark Core plaform. Some learning resources are
available at https://learn.adafruit.com/search?q=Arduino
As you can see, the app is quite simple; the app sets up the pin 7 as output. The program
turns on the LED for a second and turns it off for one second.
Now, let's discuss an example that is more or less similar to the example discussed in the
previous task:
TCPClient client;
// IP Address of the Raspberry Pi
byte server[] = { 192, 168, 1, 89 };
 
Search WWH ::




Custom Search