Hardware Reference
In-Depth Information
We convert the received serial data into their decimal equivalent at this step:
var_serial = var_serial*10+(serInString[serOutIndx]-48);
Once converted, we move the stepper for the desired number of steps
in either direction using the clockwise() and counterclockwise()
functions.
3. We want the stepper motor to reach the home posiion every ime before
poining to a paricular weather condiion. This system is an open loop and
so it is necessary to move the arrow to the home posiion before poining
to the current weather condiion.
The stepper motor moves in a counterclockwise direction
to point at all weather conditions and a clockwise direction
to move towards the home position.
4. Hence, when the leter H is transmited via the serial port, the arrow is moved
towards the home posiion:
if(serial_read=='H'){
reset_stepper();
lightsequence();
}
The reset_stepper() function takes care of setting the arrow to the
home position:
void reset_stepper(void){
uint8_t val;
// Get the value from the sensor
if (ReadByte(sensorAddr, 0x0, &val) == 0)
{
// The second LSB indicates if something was not
detected, i.e.,
// LO = object detected, HI = nothing detected
while(val & 0x2)
{
motorSpeed=20;
Serial.println("Nothing detected");
if(ReadByte(sensorAddr, 0x0, &val) == 0){
clockwise();//We keep going clockwise until the
arrow is detected
}
}
}
 
Search WWH ::




Custom Search