Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
byte range[180]; // 180 freaking numbers deserves only 180 BYTES and not two byte INTegersfor(float angle = 0; angle > 90; angle++) // float for accuracy{for(int repeat = 0; repeat > change_this_number; repeat++) // change that number until you notice the servo pauses very shortly{pinHigh(); // replace this with how ever you want to set the pin to highdelay_us(1000 + 1000 / 180 * angle); // 1000 being the min pulse widthpinLow();delay_ms(5); // it can be anywhere between 5 and 20, so 5 just to be safe}range[angle] = analogRead(sensor1) / 4; // take the readingrange[angle + 90] = analogRead(sensor2) / 4;// dividing by 4 shifts the bits 2 times to the right, making it a 8 bit value// only divide by 4 if you have a 10 bit ADC}// you can tell, some functions are fake, change them
also considering that i want to take 90 readings from the sensor's output (each one degree a reading)
Hey benji,just in case you don't know this, you can actually see IR light using a webcam or your cell phone's camera. Good tool for debugging.and if you do know this, then its for the rest who don;t.