Stock workshop Robotics and Modular Machines:

From XPUB & Lens-Based wiki
Revision as of 18:21, 6 March 2013 by Nan Wang (talk | contribs)

Robotics and Modular Machines

learning process

document photos...

for optical instrument

code:

//no moter //sensor pin const int ldrPin = A1;

//light pin const int ledPin = 13; //speaker pin const int speakerPin = 9;

void setup(){

Serial.begin(115200);
// using those pins as output
pinMode(ledPin, OUTPUT);
pinMode(speakerPin, OUTPUT);

}


void loop() {

 int ldrVal = analogRead(ldrPin);
 //map the value of the light sensor
 ldrVal = map(ldrVal, 170, 600, 0, 1023);
 //constrain the vaule from 0 to 1023
 ldrVal = constrain(ldrVal, 0, 1023);

// turning on the led

 digitalWrite(ledPin, HIGH);
 Serial.println(ldrVal);
 makeTone(ldrVal);

}

void makeTone(int freq){

   digitalWrite(speakerPin, HIGH);
   delayMicroseconds(freq);
   digitalWrite(speakerPin, LOW);
   delayMicroseconds(freq);

}

Hardware:

IMG 2901.JPG

white board :

1. 8533538957_ab70265037_m.jpg 2. 8533538907_fc8fe05d61_m.jpg

3.8534646966_8429d10f3d_m.jpg 4.8534646916_7406c2a305_m.jpg

5. 8533538707_91951352b4_m.jpg 6.8534646722_55a7a6853d_m.jpg

7.8534646606_f236361e0a_m.jpg