SlideShare une entreprise Scribd logo
1  sur  12
Télécharger pour lire hors ligne
Intel IoT Webinar
Tedison: Controlling a Robosapien from Edison
● A low cost humanoid robot
● ($62.99 on Amazon)
● Bipedal walking motion
● Infrared remote control
● Hardware for
...Toy Story…
...Child’s Play...
...Five nights at Freddies…
Robosapien...
● Robust Teddy Bear
● Low cost
● Large enough to hold a Robosapien
● Stuffing in the head is too heavy, so…
● Replace with packing peanuts
Ikea Vandring Bjorn Teddy Bear
● Edison with Arduino breakout board
● Could now be done with SparkFun blocks
● Keep the packing box as an enclosure!
● No packing box
● Infrared LED and resistor and jumper wires
● NO SOLDER….
Intel Edison
● An “Arduino Sketch” that could never run on an arduino
● Communicates using Firebase
○ A realtime cloud database with a REST API. Free for small users
○ Backend doesn’t require any coding
● Front end saves a command integer to firebase
● Intel Edison retrieves the events in the “arduino” event loop
Software
// the loop routine runs over and over again forever:
void loop() { // wait for a second
int maxfsize=500;
//Retrieve a command
system("curl https://blazing-fire-1158.firebaseio.com/robosapien.json > /tmp/robocmd.txt");
char *cmdStr = (char*)malloc(maxfsize + 1);
FILE *lockFile = fopen("/tmp/robolock", "r");
if(!lockFile)
{
FILE *cmdFile = fopen("/tmp/robocmd.txt", "rb");
if(cmdFile)
{
Retreive a command
fseek(cmdFile, 0, SEEK_END);
long fsize = ftell(cmdFile);
if(fsize<3)
{
fclose(cmdFile);
Serial.println("File length too short. Size in bytes is: ");
Serial.println(fsize);
}
else
{
Check the response is valid
fseek(cmdFile, 1, SEEK_SET); //avoid leading quote
fread(cmdStr, fsize, 1, cmdFile);
fclose(cmdFile);
cmdStr[fsize] = 0;
cmdStr[fsize-1] = 0; //delete trailing quote
int cmdInt=atoi(cmdStr);
Serial.println("Command Number");
Serial.println(cmdInt);
Convert the command to an int
if(cmdInt>=0)
{
Serial.println("Executing Command");
sendCommand(cmdInt); //0x88 high5 0x8E fart
Serial.println("Command Executed, erasing command from firebase");
system("curl -X PUT -d '"-1"' https://blazing-fire-1158.firebaseio.com/robosapien.json");
Serial.println("Command erased");
}
}
}
}
}
Execute the command
void sendCommand(unsigned char cmdIn)
{
unsigned char cmd=cmdIn;
sendHeader();
for(int i=0; i<8; i++) {
if(cmd&128)
sendOne();
else
sendZero();
cmd=cmd<<1;
}
}
Sending command
void sendHeader()
{
sendPair(headerPulse, headerSpace, waitMS);
};
void sendOne()
{
sendPair(onePulse, oneSpace, waitMS);
};
void sendZero()
{
sendPair(zeroPulse, zeroSpace, waitMS);
};
Sending zeros, ones, headers
//VERY IMPORTANT NOTE delayMicros on an Edison will delay you a minimum of 90MS!!!!
void sendPair(int p, int s, int w){
int targetMicros=micros()+p; int micros2=micros();
while(micros()<targetMicros) { //Modulate at IR frequency for the “ON” pulse
int micros1=micros2;int microsTarget=micros1+w;
digitalWrite(led, HIGH); digitalWrite(boardLED, HIGH);
while((micros2=micros())<microsTarget){} //Waiting by spinning CPU with HIGH LED
int H=micros2-micros1; micros1=micros2;
digitalWrite(led, LOW); digitalWrite(boardLED, LOW);
microsTarget=micros1+w;
while((micros2=micros())<microsTarget){} //Waiting by spinning CPU with LOW LED
}
delayMicroseconds(s); //LED low only for “OFF” pulse
}
IR Modulation

Contenu connexe

Tendances

37562259 top-consuming-process
37562259 top-consuming-process37562259 top-consuming-process
37562259 top-consuming-process
skumner
 

Tendances (20)

37562259 top-consuming-process
37562259 top-consuming-process37562259 top-consuming-process
37562259 top-consuming-process
 
【Manifes2018】私が考えるPCの"最新"学習方法
【Manifes2018】私が考えるPCの"最新"学習方法【Manifes2018】私が考えるPCの"最新"学習方法
【Manifes2018】私が考えるPCの"最新"学習方法
 
用 Bitbar Tool 寫 Script 自動擷取外幣
用 Bitbar Tool 寫 Script 自動擷取外幣用 Bitbar Tool 寫 Script 自動擷取外幣
用 Bitbar Tool 寫 Script 自動擷取外幣
 
Basics Ubuntu commands
Basics Ubuntu commandsBasics Ubuntu commands
Basics Ubuntu commands
 
How to make the Fastest C# Serializer, In the case of ZeroFormatter
How to make the Fastest C# Serializer, In the case of ZeroFormatterHow to make the Fastest C# Serializer, In the case of ZeroFormatter
How to make the Fastest C# Serializer, In the case of ZeroFormatter
 
How to ride a whale
How to ride a whaleHow to ride a whale
How to ride a whale
 
Zsh & fish: better *bash* for hackers
Zsh & fish: better *bash* for hackersZsh & fish: better *bash* for hackers
Zsh & fish: better *bash* for hackers
 
IL: 失われたプロトコル
IL: 失われたプロトコルIL: 失われたプロトコル
IL: 失われたプロトコル
 
Flex pod driven by Openstack
Flex pod driven by OpenstackFlex pod driven by Openstack
Flex pod driven by Openstack
 
Comets notes
Comets notesComets notes
Comets notes
 
Python
PythonPython
Python
 
nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry manager
 
Puppet
PuppetPuppet
Puppet
 
Slider2
Slider2Slider2
Slider2
 
仮想化環境におけるバイナリー・ポータビリティの考察 (WebAssemblyの場合)
仮想化環境におけるバイナリー・ポータビリティの考察 (WebAssemblyの場合)仮想化環境におけるバイナリー・ポータビリティの考察 (WebAssemblyの場合)
仮想化環境におけるバイナリー・ポータビリティの考察 (WebAssemblyの場合)
 
Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012Pry at the Ruby Drink-up of Sophia, February 2012
Pry at the Ruby Drink-up of Sophia, February 2012
 
My Sq Ldb Tut
My Sq Ldb TutMy Sq Ldb Tut
My Sq Ldb Tut
 
gemdiff
gemdiffgemdiff
gemdiff
 
C++
C++C++
C++
 
Great Hiroshima with Python 170830
Great Hiroshima with Python 170830Great Hiroshima with Python 170830
Great Hiroshima with Python 170830
 

En vedette

En vedette (14)

Intel Lightning Talk
Intel Lightning TalkIntel Lightning Talk
Intel Lightning Talk
 
Intel Edison
Intel EdisonIntel Edison
Intel Edison
 
Base board of intel edison for iot(english)
Base board of intel edison for iot(english)Base board of intel edison for iot(english)
Base board of intel edison for iot(english)
 
Teeth presentation by Nathan Carver
Teeth presentation by Nathan CarverTeeth presentation by Nathan Carver
Teeth presentation by Nathan Carver
 
Intel Edison: Beyond the Breadboard
Intel Edison: Beyond the BreadboardIntel Edison: Beyond the Breadboard
Intel Edison: Beyond the Breadboard
 
Iot aws-introduction
Iot aws-introductionIot aws-introduction
Iot aws-introduction
 
Intel Edison a toda potencia.
Intel Edison a toda potencia.Intel Edison a toda potencia.
Intel Edison a toda potencia.
 
IoT Knowledge Forum Slides by Deepak Gupta
IoT Knowledge Forum Slides by Deepak GuptaIoT Knowledge Forum Slides by Deepak Gupta
IoT Knowledge Forum Slides by Deepak Gupta
 
Edison pb 331179-001 (2)
Edison pb 331179-001 (2)Edison pb 331179-001 (2)
Edison pb 331179-001 (2)
 
40 IOT Innovations which are changing life
40 IOT Innovations which are changing life40 IOT Innovations which are changing life
40 IOT Innovations which are changing life
 
Intel SoC as a Platform to Connect Sensor Data to AWS
Intel SoC as a Platform to Connect Sensor Data to AWSIntel SoC as a Platform to Connect Sensor Data to AWS
Intel SoC as a Platform to Connect Sensor Data to AWS
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
 
Interacting with Intel Edison
Interacting with Intel EdisonInteracting with Intel Edison
Interacting with Intel Edison
 
Wi-Fi Technology
Wi-Fi TechnologyWi-Fi Technology
Wi-Fi Technology
 

Similaire à Intel IoT webinar #1 - Tedison presentation

Confraria SECURITY & IT - Lisbon Set 29, 2011
Confraria SECURITY & IT - Lisbon Set 29, 2011Confraria SECURITY & IT - Lisbon Set 29, 2011
Confraria SECURITY & IT - Lisbon Set 29, 2011
ricardomcm
 
Confraria Security & IT - Lisbon Set 29, 2011
Confraria Security & IT - Lisbon Set 29, 2011Confraria Security & IT - Lisbon Set 29, 2011
Confraria Security & IT - Lisbon Set 29, 2011
ricardomcm
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdf
clarityvision
 
Unit 6
Unit 6Unit 6
Unit 6
siddr
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
ChereCheek752
 

Similaire à Intel IoT webinar #1 - Tedison presentation (20)

Arduino
ArduinoArduino
Arduino
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
 
DEF CON 23 - Phil Polstra - one device to pwn them all
DEF CON 23 - Phil Polstra - one device to pwn them allDEF CON 23 - Phil Polstra - one device to pwn them all
DEF CON 23 - Phil Polstra - one device to pwn them all
 
Confraria SECURITY & IT - Lisbon Set 29, 2011
Confraria SECURITY & IT - Lisbon Set 29, 2011Confraria SECURITY & IT - Lisbon Set 29, 2011
Confraria SECURITY & IT - Lisbon Set 29, 2011
 
Confraria Security & IT - Lisbon Set 29, 2011
Confraria Security & IT - Lisbon Set 29, 2011Confraria Security & IT - Lisbon Set 29, 2011
Confraria Security & IT - Lisbon Set 29, 2011
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernel
 
Sysprog 16
Sysprog 16Sysprog 16
Sysprog 16
 
Raspberry Pi a la CFML
Raspberry Pi a la CFMLRaspberry Pi a la CFML
Raspberry Pi a la CFML
 
Raspberry pi a la cfml
Raspberry pi a la cfmlRaspberry pi a la cfml
Raspberry pi a la cfml
 
Npc14
Npc14Npc14
Npc14
 
Shell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdfShell to be modified#include stdlib.h #include unistd.h .pdf
Shell to be modified#include stdlib.h #include unistd.h .pdf
 
Sysprog 11
Sysprog 11Sysprog 11
Sysprog 11
 
Computer networkppt4577
Computer networkppt4577Computer networkppt4577
Computer networkppt4577
 
Unit 6
Unit 6Unit 6
Unit 6
 
Node js lecture
Node js lectureNode js lecture
Node js lecture
 
Facts about multithreading that'll keep you up at night - Guy Bar on, Vonage
Facts about multithreading that'll keep you up at night - Guy Bar on, VonageFacts about multithreading that'll keep you up at night - Guy Bar on, Vonage
Facts about multithreading that'll keep you up at night - Guy Bar on, Vonage
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
 
Epoll - from the kernel side
Epoll -  from the kernel sideEpoll -  from the kernel side
Epoll - from the kernel side
 
Socket Programming Intro.pptx
Socket  Programming Intro.pptxSocket  Programming Intro.pptx
Socket Programming Intro.pptx
 
Why learn Internals?
Why learn Internals?Why learn Internals?
Why learn Internals?
 

Plus de BeMyApp

Présentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM WatsonPrésentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM Watson
BeMyApp
 

Plus de BeMyApp (20)

Introduction to epid
Introduction to epidIntroduction to epid
Introduction to epid
 
Introduction ciot workshop premeetup
Introduction ciot workshop premeetupIntroduction ciot workshop premeetup
Introduction ciot workshop premeetup
 
Présentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM WatsonPrésentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM Watson
 
Crédit Agricole S.A. Personae et Parcours
Crédit Agricole S.A. Personae et ParcoursCrédit Agricole S.A. Personae et Parcours
Crédit Agricole S.A. Personae et Parcours
 
Cisco Paris DevNet Hackathon slideshow - Intro
Cisco Paris DevNet Hackathon slideshow - IntroCisco Paris DevNet Hackathon slideshow - Intro
Cisco Paris DevNet Hackathon slideshow - Intro
 
Tumeurs Neuroendocrines : une vue d'ensemble
Tumeurs Neuroendocrines : une vue d'ensembleTumeurs Neuroendocrines : une vue d'ensemble
Tumeurs Neuroendocrines : une vue d'ensemble
 
Building your first game in Unity 3d by Sarah Sexton
Building your first game in Unity 3d  by Sarah SextonBuilding your first game in Unity 3d  by Sarah Sexton
Building your first game in Unity 3d by Sarah Sexton
 
Using intel's real sense to create games with natural user interfaces justi...
Using intel's real sense to create games with natural user interfaces   justi...Using intel's real sense to create games with natural user interfaces   justi...
Using intel's real sense to create games with natural user interfaces justi...
 
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon CollinsIntroduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
 
Audio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy TouchAudio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy Touch
 
Shaders - Claudia Doppioslash - Unity With the Best
Shaders - Claudia Doppioslash - Unity With the BestShaders - Claudia Doppioslash - Unity With the Best
Shaders - Claudia Doppioslash - Unity With the Best
 
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
 
Tools to Save Time
Tools to Save TimeTools to Save Time
Tools to Save Time
 
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
 
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
 
[IoT World Forum Webinar] Review of CMX Cisco technology
[IoT World Forum Webinar] Review of CMX Cisco technology[IoT World Forum Webinar] Review of CMX Cisco technology
[IoT World Forum Webinar] Review of CMX Cisco technology
 
HP Helion Episode 6: Cloud Foundry Summit Recap
HP Helion Episode 6: Cloud Foundry Summit RecapHP Helion Episode 6: Cloud Foundry Summit Recap
HP Helion Episode 6: Cloud Foundry Summit Recap
 
Webinar UI/UX by Francesco Marcellino
Webinar UI/UX by Francesco MarcellinoWebinar UI/UX by Francesco Marcellino
Webinar UI/UX by Francesco Marcellino
 
HP Helion Webinar #5 - Security Beyond Firewalls
HP Helion Webinar #5 - Security Beyond FirewallsHP Helion Webinar #5 - Security Beyond Firewalls
HP Helion Webinar #5 - Security Beyond Firewalls
 
HP Helion Webinar #4 - Open stack the magic pill
HP Helion Webinar #4 - Open stack the magic pillHP Helion Webinar #4 - Open stack the magic pill
HP Helion Webinar #4 - Open stack the magic pill
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Intel IoT webinar #1 - Tedison presentation

  • 1. Intel IoT Webinar Tedison: Controlling a Robosapien from Edison
  • 2. ● A low cost humanoid robot ● ($62.99 on Amazon) ● Bipedal walking motion ● Infrared remote control ● Hardware for ...Toy Story… ...Child’s Play... ...Five nights at Freddies… Robosapien...
  • 3. ● Robust Teddy Bear ● Low cost ● Large enough to hold a Robosapien ● Stuffing in the head is too heavy, so… ● Replace with packing peanuts Ikea Vandring Bjorn Teddy Bear
  • 4. ● Edison with Arduino breakout board ● Could now be done with SparkFun blocks ● Keep the packing box as an enclosure! ● No packing box ● Infrared LED and resistor and jumper wires ● NO SOLDER…. Intel Edison
  • 5. ● An “Arduino Sketch” that could never run on an arduino ● Communicates using Firebase ○ A realtime cloud database with a REST API. Free for small users ○ Backend doesn’t require any coding ● Front end saves a command integer to firebase ● Intel Edison retrieves the events in the “arduino” event loop Software
  • 6. // the loop routine runs over and over again forever: void loop() { // wait for a second int maxfsize=500; //Retrieve a command system("curl https://blazing-fire-1158.firebaseio.com/robosapien.json > /tmp/robocmd.txt"); char *cmdStr = (char*)malloc(maxfsize + 1); FILE *lockFile = fopen("/tmp/robolock", "r"); if(!lockFile) { FILE *cmdFile = fopen("/tmp/robocmd.txt", "rb"); if(cmdFile) { Retreive a command
  • 7. fseek(cmdFile, 0, SEEK_END); long fsize = ftell(cmdFile); if(fsize<3) { fclose(cmdFile); Serial.println("File length too short. Size in bytes is: "); Serial.println(fsize); } else { Check the response is valid
  • 8. fseek(cmdFile, 1, SEEK_SET); //avoid leading quote fread(cmdStr, fsize, 1, cmdFile); fclose(cmdFile); cmdStr[fsize] = 0; cmdStr[fsize-1] = 0; //delete trailing quote int cmdInt=atoi(cmdStr); Serial.println("Command Number"); Serial.println(cmdInt); Convert the command to an int
  • 9. if(cmdInt>=0) { Serial.println("Executing Command"); sendCommand(cmdInt); //0x88 high5 0x8E fart Serial.println("Command Executed, erasing command from firebase"); system("curl -X PUT -d '"-1"' https://blazing-fire-1158.firebaseio.com/robosapien.json"); Serial.println("Command erased"); } } } } } Execute the command
  • 10. void sendCommand(unsigned char cmdIn) { unsigned char cmd=cmdIn; sendHeader(); for(int i=0; i<8; i++) { if(cmd&128) sendOne(); else sendZero(); cmd=cmd<<1; } } Sending command
  • 11. void sendHeader() { sendPair(headerPulse, headerSpace, waitMS); }; void sendOne() { sendPair(onePulse, oneSpace, waitMS); }; void sendZero() { sendPair(zeroPulse, zeroSpace, waitMS); }; Sending zeros, ones, headers
  • 12. //VERY IMPORTANT NOTE delayMicros on an Edison will delay you a minimum of 90MS!!!! void sendPair(int p, int s, int w){ int targetMicros=micros()+p; int micros2=micros(); while(micros()<targetMicros) { //Modulate at IR frequency for the “ON” pulse int micros1=micros2;int microsTarget=micros1+w; digitalWrite(led, HIGH); digitalWrite(boardLED, HIGH); while((micros2=micros())<microsTarget){} //Waiting by spinning CPU with HIGH LED int H=micros2-micros1; micros1=micros2; digitalWrite(led, LOW); digitalWrite(boardLED, LOW); microsTarget=micros1+w; while((micros2=micros())<microsTarget){} //Waiting by spinning CPU with LOW LED } delayMicroseconds(s); //LED low only for “OFF” pulse } IR Modulation