Wednesday, November 27, 2013

Programming and codes.

Along with our components, we also had to some coding. Coding is the harder part of the project I would think. We have a simple one to start.

******************************************************************************************************************************************************************

#include <Servo.h> 

Servo myservo;
void setup()
{
  myservo.attach(9);
  Serial.begin(9600); //open serial port, set the baud rate to 9600 bps
}
void loop()
{
  int val;
  val=analogRead(5); //connect mic sensor to Analog 0
  Serial.println(val,DEC); //print the sound value to serial
  delay(50 );
  val=map(val, 0, 1023,0,255);
  analogWrite(11,val);
  myservo.write(val);
}


******************************************************************************************************************************************************************

This what we have so far, it should make the sound sensor work. We'll still need to modify it to accommodate for the blinking led. That should be simple though. Things are looking well for us. 

No comments:

Post a Comment