31.07.2015 Views

A-Teachers-Guide-to-the-Intel-Galileo-Final

A-Teachers-Guide-to-the-Intel-Galileo-Final

A-Teachers-Guide-to-the-Intel-Galileo-Final

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A TEACHER’S GUIDE TO THE INTEL® GALILEO | 7215. Click on <strong>the</strong> Back but<strong>to</strong>n <strong>to</strong> return <strong>to</strong> <strong>the</strong> Scenario page.16. You can now test your scenario by clicking on Test Scenario.17. You should receive a mobile phone message.When you call pushingbox with <strong>the</strong> DeviceId of this scenario, you will prompt <strong>the</strong> associatedaction <strong>to</strong> occur. In our case, <strong>to</strong> send a text message <strong>to</strong> our connected mobile. We will use ourArduino code <strong>to</strong> call pushingbox.The Arduino programThe Arduino program simply makes a call <strong>to</strong> <strong>the</strong> pushingbox service. Upload <strong>the</strong> followingsketch:void setup() {// put your setup code here, <strong>to</strong> run once:Serial.begin(9600);pinMode(2, INPUT); // connect your switch between Pin 2 and 5VpinMode(12, OUTPUT); // connect an LED so you know when you are sending}void loop() {// put your main code here, <strong>to</strong> run repeatedly:int sensorValue = digitalRead(2);digitalWrite(12, sensorValue);if (digitalRead(2) == HIGH) {system("curl 'http://api.pushingbox.com/pushingbox?devid=vXXXXXXXXXXXX' > /dev/ttyGS0"); // put your devid instead of XXXX}delay(500);}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!