Close

13-2-2019

A project log for Arduino based sonar tower

The goal is to make an arduino based sonar tower which scans and displays the direct enviroment.

vincent-dankbaarVincent Dankbaar 02/13/2019 at 19:170 Comments

All the parts for the stepper assembly arrived.

1 hour: Setup and soldering

30 minutes: Connecting the parts and running a simple test script

//Test script

// defines pins numbers
const int stepPin = 3; 
const int dirPin = 4; 
 
void setup() {
  // Sets the two pins as Outputs
  pinMode(stepPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);
}
void loop() {
  digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction

  // 200 pulses = full rotation
  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin,HIGH); 
    delayMicroseconds(1000); 
    digitalWrite(stepPin,LOW); 
    delayMicroseconds(1000); 
  }
  delay(1000);
  
  digitalWrite(dirPin,LOW); //Changes the rotations direction
  // 400 pulses == 2 rotations
  for(int x = 0; x < 400; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(1000);
  }
  delay(1000);
}

The correct color order left to right with the pot on the left side is: Red-Green-

Discussions