Monday, November 12, 2018

Serial input - Unlock the door for person b

/*Using the small servo in pin 6, power in VIN, and black wire in GND
* wire for red LED in pin 13, wire for green LED in pin 7
*/

// Wei's demo of if-else-if statement, plus a Servo door lock!
#include<Servo.h>
Servo DoorLock;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT); //The led is in PIN 13
DoorLock.attach(6);
Serial.println("WELCOME !");
}

char who=0;

void loop() {
  // put your main code here, to run repeatedly:
Serial.println("who are you?");
if(Serial.available()>0){
who=Serial.read();
}
if(who=='a') {
digitalWrite(13,HIGH);

digitalWrite(7,LOW);
delay(500);
Serial.println("person a wants to enter the building");
}

else if(who=='b') {
digitalWrite(7,HIGH);

digitalWrite(13,LOW);

Serial.println("person b is allowed to enter the building");
DoorLock.write(90)
delay(2500);
DoorLock.write(0);
}

}

Serial input and monitoring - Who's at the door?

// Wei's demo of if-else-if statement.

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT); //The led is in PIN 13
Serial.println("who are you?");
}

char who=0;

void loop() {
  // put your main code here, to run repeatedly:
if(Serial.available()>0){
who=Serial.read();
}
if(who=='a') {
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
Serial.println("person a wants to enter the building");
}

else if(who=='b') {
digitalWrite(13,HIGH);
delay(250);
digitalWrite(13,LOW);
delay(250);
Serial.println("person b wants to enter the building");
}

}

Thursday, November 8, 2018

Serial monitoring for Arduino sketches

Open Arduino, then use FILE, NEW.

Select and replace that template with the following.  Colors will appear automatically.

=====================================


#include<Servo.h>
Servo HokieServo;    // My first servo is named HokieServo

void setup() {
  // put your setup code here, to run once:
HokieServo.attach(6);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
HokieServo.write(45);
Serial.println("\t  Speed is 45 - left, medium speed");
delay(1000);
HokieServo.write(135);
Serial.println("\t  Speed is 135 - right, medium speed");
delay(1000);
}

Saturday, November 3, 2018

New WiFi, New Sensors


from www.Wired.Com

EMILY DREYFUSS
BUSINESS
10.30.1812:01 AM

IBM’S CALL FOR CODE PRIZE GOES TO A TEAM WITH ‘CLUSTERDUCKS’



Buoys equipped with a low-frequency Wi-Fi network could provide a lifeline to people in areas struck by natural disasters.
PROJECT OWL/IBM

YOU KNOW WHEN you try to go online at a Starbucks or on an airplane, first you get a little popup that asks you to accept some terms before you can get to the internet? That popup window exists in a sort of netherworld between actual internet connection and being offline–you pick it up via Wi-Fi, but until you click a box, you’re not actually online. A team of five developers realized in that gray area was potentially a huge opportunity to save lives.
It’s an intractable problem during natural disasters: telecommunications networks and power grids are often damaged or overwhelmed; without them, first responders struggle to help survivors, coordinate evacuations, and even count the dead. Project Owl proposes an elegant solution: an AI-powered disaster coordination platform paired with a robust communication network that can