Today, I looked up some resources available on https://www.arduino.cc/en/Guide/HomePage .
The best way to learn the language and how to work the microcontroller is to try on a project, so I intend to try one today.

Project: Distance Sensor
Link: https://www.makeuseof.com/tag/how-to-make-a-simple-arduino-alarm-system/

What was accomplished today was mainly understanding how the ultrasound sensor works. The code itself is a little complicated and is taking a little while for me to understand and write my own version of what I see.

The code below was obtained from the Arduino website:

 unsigned long echo = 0;
int ultraSoundSignal = 9; // Ultrasound signal pin
unsigned long ultrasoundValue = 0;
void setup()
{
  Serial.begin(9600);
  pinMode(ultraSoundSignal,OUTPUT);
}
unsigned long ping()
{
  pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output
  digitalWrite(ultraSoundSignal, LOW); // Send low pulse
  delayMicroseconds(2); // Wait for 2 microseconds
  digitalWrite(ultraSoundSignal, HIGH); // Send high pulse
  delayMicroseconds(5); // Wait for 5 microseconds
  digitalWrite(ultraSoundSignal, LOW); // Holdoff
  pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
  digitalWrite(ultraSoundSignal, HIGH); // Turn on pullup resistor
  // please note that pulseIn has a 1sec timeout, which may
  // not be desirable. Depending on your sensor specs, you
  // can likely bound the time like this -- marcmerlin
  // echo = pulseIn(ultraSoundSignal, HIGH, 38000)
  echo = pulseIn(ultraSoundSignal, HIGH); //Listen for echo
  ultrasoundValue = (echo / 58.138) * .39; //convert to CM then to inches
  return ultrasoundValue;
}
void loop()
{
  int x = 0;
  x = ping();
  Serial.println(x);
  delay(250); //delay 1/4 seconds.
}


As of now, Ramya is trying to attach the servomotor to the prosthetic hand, and I am setting something to print.


Comments

Popular Posts