Wednesday, November 9, 2016

Week 11

This week, Luis and I simply worked on salvaging pieces of code from the 2016 summer team's Arduino code. So far, I've determined that the entire sketch for the Arduino Micro could be used for our code because it simply controls the ultrasonic sensor and communicates that information to the Arduino Uno. The Arduino Micro communicates by using pin 13 to simply write a value of HIGH or LOW to pin 6 on the Arduino Uno. The code can be seen below:

#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define STOP 13 // emergency stop

int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance
int stop_counter = 0;
int restar_counter = 0;
void setup() {
 Serial.begin (57600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(STOP, OUTPUT);

Therefore, the code on the Arduino Uno that corresponds with the sketch above can be observed below. The code simply reads pin 6 and stops the bogie if the value is HIGH.

int emer = digitalRead(emergency_stop); 
if ( emer == HIGH) 
{
  control_rpm = 0 ;          
  STOP = true;        

  }

Currently, I am helping Luis with understanding more of the summer team's code such that we could salvage more pieces of it. Hopefully, we can begin writing in some of our own code and begin testing all the vehicle controls components.

No comments:

Post a Comment