Published © CC BY

CabiNET

Connected to your children's stomach!

IntermediateWork in progress2 hours225
CabiNET

Things used in this project

Hardware components

IOTOPIA Rapid Development kit
AllThingsTalk IOTOPIA Rapid Development kit
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Prototype code

Arduino
With this code, the wanted type of cookie can be chosen and with a press of the button an actuator (LED in prototype) will be activated.
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,INPUT);
int button = 0;
}

void loop() {
  // put your main code here, to run repeatedly:
int pot = analogRead(A0);
Serial.println(pot);
int button = digitalRead(5);
if (pot > 1000 && button == 1 ) {
  digitalWrite(4,HIGH);
  delay(2000);
  digitalWrite(4,LOW);
}
if (pot > 300 && pot < 700 && button == 1){
  digitalWrite(3,HIGH);
  delay(2000);
  digitalWrite(3,LOW);
}
if (300 > pot && button == 1) {
  digitalWrite(2,HIGH);
  delay(2000);
  digitalWrite(2,LOW);  
}
}

Credits

Comments