DIY Robo Tank #2
Thursday, April 18, 2019
Ismael pm what i did for open lab
what i did foe open lab is is the the SR latch for my 8 bit computer project
Tuesday, April 16, 2019
Friday, March 29, 2019
Ismael-PM-35 min- Fixing arduino after lab
Next step
- Add the fourth sensor
- Add wires to the sensor
- Add code for the sensor
What Ismael did today
- I uploaded the code on the arduino because we had lab using the arduino and rasbarry pi
- I change the code on the distance
- The code work on three of the sensor
What Nicholas did today
- He fix the wire on the arduino because of today lab
- He checked to see if the wires are on the correct pins
- All three of the sensors work because they were on the correct pi
Ultrasonic Sensor HC-SR04 and Arduino Tutorial
www.HowToMechatronics.com
*/
// Left Motor
const int leftDirControl1 = 2;
const int leftDirControl2 = 3;
const int leftSpeedControlPin = 4; // Needs to be a PWM pin to be able to control motor speed
// Right Motor
const int rightDirControl1 = 5;
const int rightDirControl2 = 6;
const int rightSpeedControlPin = 7; // Needs to be a PWM pin to be able to control motor speed
byte carSpeed = 0; // change this (0-100) to control the speed of the motors
byte leftSpeed = 0; // change this (0-100) to control the speed of the motors
byte rightSpeed = 0; // change this (0-100) to control the speed of the motors
char carDirection = 'S'; // S=STOP, F=Forward, B=Reverse
char leftDirection = 'S'; // S=STOP, F=Forward, B=Reverse
char rightDirection = 'S'; // S=STOP, F=Forward, B=Reverse
// defines pins numbers
const int trigPin1 = 9;
const int echoPin1 = 10;
const int trigPin2 = 12;
const int echoPin2 = 8;
const int trigPin3 = 13;
const int echoPin3 = 11;
// defines variables
long duration1;
int distance1;
long duration2;
int distance2;
long duration3;
int distance3;
void setup() {
pinMode(trigPin1, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin1, INPUT); // Sets the echoPin as an Input
pinMode(trigPin2, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin2, INPUT); // Sets the echoPin as an Input
pinMode(trigPin3, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin3, INPUT); // Sets the echoPin as an Input
//Define L298N Dual H-Bridge Motor Controller Pins
pinMode(leftDirControl1, OUTPUT);
pinMode(leftDirControl2, OUTPUT);
pinMode(leftSpeedControlPin, OUTPUT);
pinMode(rightDirControl1, OUTPUT);
pinMode(rightDirControl2, OUTPUT);
pinMode(rightSpeedControlPin, OUTPUT);
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600); // Starts the serial communication
allDriveMotorsStop();
}
void loop() {
// Clears the trigPin 1
digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
// Sets the trigPin 1 on HIGH state for 10 micro seconds
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration1 = pulseIn(echoPin1, HIGH);
// Clears the trigPin 2
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
// Sets the trigPin 2 on HIGH state for 10 micro seconds
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration2 = pulseIn(echoPin2, HIGH);
// Clears the trigPin 3
digitalWrite(trigPin3, LOW);
delayMicroseconds(2);
// Sets the trigPin 3 on HIGH state for 10 micro seconds
digitalWrite(trigPin3, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin3, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration3 = pulseIn(echoPin3, HIGH);
// Calculating the distance
distance1 = duration1 * 0.034 / 2;
distance2 = duration2 * 0.034 / 2;
distance3 = duration3 * 0.034 / 2;
Serial.print("Distance1: ");
Serial.println(distance1);
Serial.print(" Distance2: ");
Serial.println(distance2);
Serial.print(" Distance3: ");
Serial.println(distance3);
delay(1000);
// if (distance1 > 10) {
// // write code that does something when your distance threshhold is found
// //alarm();
// allDriveMotorsStop();
// delay(2000);
// allDriveMotorsReverse(100);
// delay(500);
// DriveMotorsLeftBack(100);
// delay(500);
// Serial.println("less than 10");
// }
// else {
// // write code that does something when your distance threshhold is NOT found
// digitalWrite(LED_BUILTIN, HIGH);
// Serial.print(distance1);
// allDriveMotorsForward(150);
// Serial.println(" is more than 10");
// }
//
// // Prints the distance on the Serial Monitor
// Serial.print("Distance: ");
// Serial.println(distance1);
}
void allDriveMotorsStop()
{
analogWrite(leftSpeedControlPin, 0);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, 0);//Sets speed variable via PWM
digitalWrite(leftDirControl1, LOW);
digitalWrite(leftDirControl2, LOW);
digitalWrite(rightDirControl1, LOW);
digitalWrite(rightDirControl2, LOW);
Serial.println("All Motors STOPPED");
}
int allDriveMotorsForward(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, LOW);
digitalWrite(leftDirControl2, HIGH);
digitalWrite(rightDirControl1, LOW);
digitalWrite(rightDirControl2, HIGH);
Serial.print("car is Forward at a speed of ");
Serial.println(carSpeed);
}
int allDriveMotorsReverse(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, HIGH);
digitalWrite(leftDirControl2, LOW);
digitalWrite(rightDirControl1, HIGH);
digitalWrite(rightDirControl2, LOW);
Serial.print("car is Reverse at a speed of ");
Serial.println(carSpeed);
}
int DriveMotorsLeftBack(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, HIGH);
digitalWrite(leftDirControl2, LOW);
digitalWrite(rightDirControl1, LOW);
digitalWrite(rightDirControl2, HIGH);
Serial.print("car is Reverse at a speed of ");
Serial.println(carSpeed);
}
int DriveMotorsRightBack(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, LOW);
digitalWrite(leftDirControl2, HIGH);
digitalWrite(rightDirControl1, HIGH);
digitalWrite(rightDirControl2, LOW);
Serial.print("car is Reverse at a speed of ");
Serial.println(carSpeed);
}
ns
Wednesday, March 27, 2019
Ismael-PM-40 min-What we did for robot club
Next step
What Ismael did today
- Add the fourth sensor
- Add wires to the sensor
- Add code for the sensor
What Ismael did today
- I fix the code on the sensor
- I run the code and it work
- The serial monitor work
What Nicholas did today
- He fix the wires on the sensor and arduino
- He help me with the code
- He rearrange the wires for ground (GND)
- He rearrange the wires for power(VCC)
/*
Ultrasonic Sensor HC-SR04 and Arduino Tutorial
by Dejan Nedelkovski,
www.HowToMechatronics.com
*/
// Left Motor
const int leftDirControl1 = 2;
const int leftDirControl2 = 3;
const int leftSpeedControlPin = 4; // Needs to be a PWM pin to be able to control motor speed
// Right Motor
const int rightDirControl1 = 5;
const int rightDirControl2 = 6;
const int rightSpeedControlPin = 7; // Needs to be a PWM pin to be able to control motor speed
byte carSpeed = 0; // change this (0-100) to control the speed of the motors
byte leftSpeed = 0; // change this (0-100) to control the speed of the motors
byte rightSpeed = 0; // change this (0-100) to control the speed of the motors
char carDirection = 'S'; // S=STOP, F=Forward, B=Reverse
char leftDirection = 'S'; // S=STOP, F=Forward, B=Reverse
char rightDirection = 'S'; // S=STOP, F=Forward, B=Reverse
// defines pins numbers
const int trigPin1 = 9;
const int echoPin1 = 10;
const int trigPin2 = 12;
const int echoPin2 = 8;
const int trigPin3 = 13;
const int echoPin3 = 11;
// defines variables
long duration1;
int distance1;
long duration2;
int distance2;
long duration3;
int distance3;
void setup() {
pinMode(trigPin1, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin1, INPUT); // Sets the echoPin as an Input
pinMode(trigPin2, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin2, INPUT); // Sets the echoPin as an Input
pinMode(trigPin3, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin3, INPUT); // Sets the echoPin as an Input
//Define L298N Dual H-Bridge Motor Controller Pins
pinMode(leftDirControl1, OUTPUT);
pinMode(leftDirControl2, OUTPUT);
pinMode(leftSpeedControlPin, OUTPUT);
pinMode(rightDirControl1, OUTPUT);
pinMode(rightDirControl2, OUTPUT);
pinMode(rightSpeedControlPin, OUTPUT);
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600); // Starts the serial communication
allDriveMotorsStop();
}
void loop() {
// Clears the trigPin 1
digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
// Sets the trigPin 1 on HIGH state for 10 micro seconds
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration1 = pulseIn(echoPin1, HIGH);
// Clears the trigPin 2
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
// Sets the trigPin 2 on HIGH state for 10 micro seconds
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration2 = pulseIn(echoPin2, HIGH);
// Clears the trigPin 3
digitalWrite(trigPin3, LOW);
delayMicroseconds(2);
// Sets the trigPin 3 on HIGH state for 10 micro seconds
digitalWrite(trigPin3, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin3, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration3 = pulseIn(echoPin3, HIGH);
// Calculating the distance
distance1 = duration1 * 0.034 / 2;
distance2 = duration2 * 0.034 / 2;
distance3 = duration3 * 0.034 / 2;
Serial.print("Distance1: ");
Serial.println(distance1);
Serial.print(" Distance2: ");
Serial.println(distance2);
Serial.print(" Distance3: ");
Serial.println(distance3);
delay(1000);
// if (distance1 > 10) {
// // write code that does something when your distance threshhold is found
// //alarm();
// allDriveMotorsStop();
// delay(2000);
// allDriveMotorsReverse(100);
// delay(500);
// DriveMotorsLeftBack(100);
// delay(500);
// Serial.println("less than 10");
// }
// else {
// // write code that does something when your distance threshhold is NOT found
// digitalWrite(LED_BUILTIN, HIGH);
// Serial.print(distance1);
// allDriveMotorsForward(150);
// Serial.println(" is more than 10");
// }
//
// // Prints the distance on the Serial Monitor
// Serial.print("Distance: ");
// Serial.println(distance1);
}
void allDriveMotorsStop()
{
analogWrite(leftSpeedControlPin, 0);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, 0);//Sets speed variable via PWM
digitalWrite(leftDirControl1, LOW);
digitalWrite(leftDirControl2, LOW);
digitalWrite(rightDirControl1, LOW);
digitalWrite(rightDirControl2, LOW);
Serial.println("All Motors STOPPED");
}
int allDriveMotorsForward(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, LOW);
digitalWrite(leftDirControl2, HIGH);
digitalWrite(rightDirControl1, LOW);
digitalWrite(rightDirControl2, HIGH);
Serial.print("car is Forward at a speed of ");
Serial.println(carSpeed);
}
int allDriveMotorsReverse(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, HIGH);
digitalWrite(leftDirControl2, LOW);
digitalWrite(rightDirControl1, HIGH);
digitalWrite(rightDirControl2, LOW);
Serial.print("car is Reverse at a speed of ");
Serial.println(carSpeed);
}
int DriveMotorsLeftBack(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, HIGH);
digitalWrite(leftDirControl2, LOW);
digitalWrite(rightDirControl1, LOW);
digitalWrite(rightDirControl2, HIGH);
Serial.print("car is Reverse at a speed of ");
Serial.println(carSpeed);
}
int DriveMotorsRightBack(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, LOW);
digitalWrite(leftDirControl2, HIGH);
digitalWrite(rightDirControl1, HIGH);
digitalWrite(rightDirControl2, LOW);
Serial.print("car is Reverse at a speed of ");
Serial.println(carSpeed);
}
Monday, March 25, 2019
Ismael-PM-40 min- connecting an ultra sonic sensor
Next step
- Fix the code for the third sensor
- Then we add another sensor
- Add code for the fourth sensor
What did Ismael did today
- I change the code to distance 3
- I change the echo pin and distance pin
- I cheek the code
What did Nicholas did today
- He search for wires
- He connect the wires to the sensor
- He also connect to the breadborad
Thursday, March 21, 2019
Ismael-PM-40 min-This is what we did for robot club
Next step
I change the measure to serial print for distance 2
I change the code to print the distance for distance 2
I ran the code on the serial monitar and it work
This is aware project code
- Add 2 more ultrasonic sensor to the arduino
- Add more code to fit the two 2 sensors
- Add more wiring to connect the sensors to the arduino
What Ismael did
- I change the measure to serial print for distance 1
- I change the code to print the distance for distance 1
- I ran the code and it work
What Nicholas did
/*
Ultrasonic Sensor HC-SR04 and Arduino Tutorial
by Dejan Nedelkovski,
www.HowToMechatronics.com
*/
// Left Motor
const int leftDirControl1 = 2;
const int leftDirControl2 = 3;
const int leftSpeedControlPin = 4; // Needs to be a PWM pin to be able to control motor speed
// Right Motor
const int rightDirControl1 = 5;
const int rightDirControl2 = 6;
const int rightSpeedControlPin = 7; // Needs to be a PWM pin to be able to control motor speed
byte carSpeed = 0; // change this (0-100) to control the speed of the motors
byte leftSpeed = 0; // change this (0-100) to control the speed of the motors
byte rightSpeed = 0; // change this (0-100) to control the speed of the motors
char carDirection = 'S'; // S=STOP, F=Forward, B=Reverse
char leftDirection = 'S'; // S=STOP, F=Forward, B=Reverse
char rightDirection = 'S'; // S=STOP, F=Forward, B=Reverse
// defines pins numbers
const int trigPin1 = 9;
const int echoPin1 = 10;
const int trigPin2 = 12;
const int echoPin2 = 8;
// defines variables
long duration1;
int distance1;
long duration2;
int distance2;
void setup() {
pinMode(trigPin1, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin1, INPUT); // Sets the echoPin as an Input
pinMode(trigPin2, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin2, INPUT); // Sets the echoPin as an Input
//Define L298N Dual H-Bridge Motor Controller Pins
pinMode(leftDirControl1, OUTPUT);
pinMode(leftDirControl2, OUTPUT);
pinMode(leftSpeedControlPin, OUTPUT);
pinMode(rightDirControl1, OUTPUT);
pinMode(rightDirControl2, OUTPUT);
pinMode(rightSpeedControlPin, OUTPUT);
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600); // Starts the serial communication
allDriveMotorsStop();
}
void loop() {
// Clears the trigPin 1
digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
// Sets the trigPin 1 on HIGH state for 10 micro seconds
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration1 = pulseIn(echoPin1, HIGH);
// Clears the trigPin 2
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
// Sets the trigPin 2 on HIGH state for 10 micro seconds
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration2 = pulseIn(echoPin2, HIGH);
// Calculating the distance
distance1 = duration1 * 0.034 / 2;
distance2 = duration2 * 0.034 / 2;
Serial.print("Distance1: ");
Serial.println(distance1);
Serial.print(" Distance2: ");
Serial.println(distance2);
delay(1000);
// if (distance1 > 10) {
// // write code that does something when your distance threshhold is found
// //alarm();
// allDriveMotorsStop();
// delay(2000);
// allDriveMotorsReverse(100);
// delay(500);
// DriveMotorsLeftBack(100);
// delay(500);
// Serial.println("less than 10");
// }
// else {
// // write code that does something when your distance threshhold is NOT found
// digitalWrite(LED_BUILTIN, HIGH);
// Serial.print(distance1);
// allDriveMotorsForward(150);
// Serial.println(" is more than 10");
// }
//
// // Prints the distance on the Serial Monitor
// Serial.print("Distance: ");
// Serial.println(distance1);
}
void allDriveMotorsStop()
{
analogWrite(leftSpeedControlPin, 0);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, 0);//Sets speed variable via PWM
digitalWrite(leftDirControl1, LOW);
digitalWrite(leftDirControl2, LOW);
digitalWrite(rightDirControl1, LOW);
digitalWrite(rightDirControl2, LOW);
Serial.println("All Motors STOPPED");
}
int allDriveMotorsForward(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, LOW);
digitalWrite(leftDirControl2, HIGH);
digitalWrite(rightDirControl1, LOW);
digitalWrite(rightDirControl2, HIGH);
Serial.print("car is Forward at a speed of ");
Serial.println(carSpeed);
}
int allDriveMotorsReverse(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, HIGH);
digitalWrite(leftDirControl2, LOW);
digitalWrite(rightDirControl1, HIGH);
digitalWrite(rightDirControl2, LOW);
Serial.print("car is Reverse at a speed of ");
Serial.println(carSpeed);
}
int DriveMotorsLeftBack(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, HIGH);
digitalWrite(leftDirControl2, LOW);
digitalWrite(rightDirControl1, LOW);
digitalWrite(rightDirControl2, HIGH);
Serial.print("car is Reverse at a speed of ");
Serial.println(carSpeed);
}
int DriveMotorsRightBack(int carSpeed)
{
analogWrite(leftSpeedControlPin, carSpeed);//Sets speed variable via PWM
analogWrite(rightSpeedControlPin, carSpeed);//Sets speed variable via PWM
digitalWrite(leftDirControl1, LOW);
digitalWrite(leftDirControl2, HIGH);
digitalWrite(rightDirControl1, HIGH);
digitalWrite(rightDirControl2, LOW);
Serial.print("car is Reverse at a speed of ");
Serial.println(carSpeed);
}
Wednesday, March 20, 2019
Ismael-PM-90 min- What did I do in Robot Club
Next step
- We need to add more coding for the sensor to measure distance.
- We need to add code on the second sensor to make the motors move.
- We need to change the code to find on the other arduino.
What Ismael did today
- I added variables code to the second sensor.
- I change the distance code to distance 2.
- I change the pins in the code.
What Nicholas did today
- He help me with the code.
- He change the wires on the arduino to the breadboard.
- He connect the second sensor to the arduino and the breadboard.
Subscribe to:
Posts (Atom)