From 253b440f8ec652221bff67e94d904d9c4d58546e Mon Sep 17 00:00:00 2001 From: Hedfi Wassim <118697478+WassimHedfi@users.noreply.github.com> Date: Wed, 27 Sep 2023 23:55:52 +0100 Subject: [PATCH] Delete Robothon directory --- Robothon/1-IR_workshop1/IR_workshop1.ino | 28 --- Robothon/2-US_workshop2/US_workshop2.ino | 43 ---- .../3-l298n_workshop3/l298n_workshop3.ino | 109 ---------- Robothon/4-RC_workshop4/RC_workshop4.ino | 190 ------------------ Robothon/IR_workshop1/IR_workshop1.ino | 28 --- Robothon/RC_workshop4/RC_workshop4.ino | 190 ------------------ Robothon/US_workshop2/US_workshop2.ino | 43 ---- Robothon/l298n_workshop3/l298n_workshop3.ino | 109 ---------- 8 files changed, 740 deletions(-) delete mode 100644 Robothon/1-IR_workshop1/IR_workshop1.ino delete mode 100644 Robothon/2-US_workshop2/US_workshop2.ino delete mode 100644 Robothon/3-l298n_workshop3/l298n_workshop3.ino delete mode 100644 Robothon/4-RC_workshop4/RC_workshop4.ino delete mode 100644 Robothon/IR_workshop1/IR_workshop1.ino delete mode 100644 Robothon/RC_workshop4/RC_workshop4.ino delete mode 100644 Robothon/US_workshop2/US_workshop2.ino delete mode 100644 Robothon/l298n_workshop3/l298n_workshop3.ino diff --git a/Robothon/1-IR_workshop1/IR_workshop1.ino b/Robothon/1-IR_workshop1/IR_workshop1.ino deleted file mode 100644 index c61d1e7..0000000 --- a/Robothon/1-IR_workshop1/IR_workshop1.ino +++ /dev/null @@ -1,28 +0,0 @@ -/* -ROBOTHON ELECTRONIX ENSTAB -Workshop 1 : IR Sensor -Copy and Paste this code on your Arduino IDE - - -This code is delicately typed by the ELECTRONIX Club for whom this may be of concern -HEDFI Wassim. -*/ - - -#define sensor 9 // Call the sensor's output pin(9) as sensor, this will help when you need to change the pin, for any reason - // if you want to change the pin number you want have to do so for all the code (wherever you used the pin 9), but just change it here - // you want to call the sensor pin in the code ? just type sensor ! -int sensorValue ; // Create an empty variable to store the sonsor's reading - -void setup() { - -pinMode(sensor,INPUT); // Set the pin 'sensor'(9) to INPUT Mode; our Arduino will receive data from the sensor, hence this pin should be input -Serial.begin(9600); // This will set the our Arduino to cmmunicate with the Serial Monitor of the Arduino IDE with a bandwidth of 9600 -} - -void loop() { - // put your main code here, to run repeatedly: -sensorValue=digitalRead(sensor); // the function "digitalRead" reads the value on the pin 'sensor'(9) and return a value of 0 or 1 -Serial.println(sensorValue); // The function 'Serial.println' will write the value on the Serial Monitor - -} diff --git a/Robothon/2-US_workshop2/US_workshop2.ino b/Robothon/2-US_workshop2/US_workshop2.ino deleted file mode 100644 index 5da777c..0000000 --- a/Robothon/2-US_workshop2/US_workshop2.ino +++ /dev/null @@ -1,43 +0,0 @@ -/* -ROBOTHON ELECTRONIX ENSTAB -Workshop 2 : Ultrasonic Sensor -Copy and Paste this code on your Arduino IDE - - -This code is delicately typed by the ELECTRONIX Club for whom this may be of concern -HEDFI Wassim. -*/ - - -#define echoPin A3 // attacher echo du capteur ultrason a la pin A3 de la carte -#define trigPin A2 // attacher trig du capteur ultrason a la pin A2 de la carte - -void setup() { - // put your setup code here, to run once: - pinMode(echoPin, INPUT); // echopin is an input for the Arduino board - pinMode(trigPin,OUTPUT); - Serial.begin(9600); // you saw this before ;) - -} - -void loop() { - // put your main code here, to run repeatedly: -//***calcul de distance à l'aide du capteur ultrason - - digitalWrite(trigPin, LOW); // initialize the trigger at 0 (LOW) - delayMicroseconds(2); // keep it at zero for 2ms - digitalWrite(trigPin, HIGH); // send a pulse (HIGH) on the trigger - delayMicroseconds(10); // send the high pulse for 10ms - digitalWrite(trigPin, LOW); // put it back at zero - - float duration = pulseIn(echoPin, HIGH); // the function 'pulsin' acts as a chronometer - // when you call it it will start counting time and stop when echoPin is high and returns the duration - // Calculating the distance - float distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (from the sensor to the object and back == double the distance we want to calculate) - float distanceCentimeter; // create a variable to store the distance - if (distance>200) distanceCentimeter = 200; // ultrasonic sensor will give faulty measures for distances over 200cm, so the max distance we will define is 200cm - else distanceCentimeter= distance; - - Serial.println(distanceCentimeter); // print the distance on the Seiral monitor - delay(500); // make a little delay to not saturate the monitor -} diff --git a/Robothon/3-l298n_workshop3/l298n_workshop3.ino b/Robothon/3-l298n_workshop3/l298n_workshop3.ino deleted file mode 100644 index 1cae227..0000000 --- a/Robothon/3-l298n_workshop3/l298n_workshop3.ino +++ /dev/null @@ -1,109 +0,0 @@ -/* -ROBOTHON ELECTRONIX ENSTAB -Workshop 2 : Ultrasonic Sensor -Copy and Paste this code on your Arduino IDE - - -This code is delicately typed by the ELECTRONIX Club for whom this may be of concern -HEDFI Wassim. -*/ - - - -#define ENABLE_1_PIN 10 // This should be a pwm (~) pin -#define MOTOR_1_INPUT_1 9 -#define MOTOR_1_INPUT_2 8 -#define MOTOR_2_INPUT_1 7 -#define MOTOR_2_INPUT_2 6 -#define ENABLE_2_PIN 5 // This should be a pwm (~) pin - - - - -#define MAX_MOTOR_SPEED 200 -#define SLOW_MOTOR_SPEED 80 -#define NORMAL_MOTOR_SPEED 100 - - - -void setup() { - pinMode(MOTOR_1_INPUT_1, OUTPUT); // DEFINE - pinMode(MOTOR_1_INPUT_2, OUTPUT); // MOTOR - pinMode(MOTOR_2_INPUT_1, OUTPUT); // DRIVER - pinMode(MOTOR_2_INPUT_2, OUTPUT); // PINS - pinMode(ENABLE_1_PIN, OUTPUT); // AS - pinMode(ENABLE_2_PIN, OUTPUT); // OUTPUT -} - -void forward(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} - -void reverse(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, HIGH); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, HIGH); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void sharpleft(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, HIGH); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} -void left(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void sharpright(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, HIGH); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} -void right(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} -void stopBot(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - - - -void loop() { -forward(NORMAL_MOTOR_SPEED); -delay(2000); -sharpright(NORMAL_MOTOR_SPEED); -delay(2000); -sharpleft(NORMAL_MOTOR_SPEED); -delay(2000); -reverse(NORMAL_MOTOR_SPEED); -delay(2000); -} \ No newline at end of file diff --git a/Robothon/4-RC_workshop4/RC_workshop4.ino b/Robothon/4-RC_workshop4/RC_workshop4.ino deleted file mode 100644 index 9598493..0000000 --- a/Robothon/4-RC_workshop4/RC_workshop4.ino +++ /dev/null @@ -1,190 +0,0 @@ -/* -ROBOTHON ELECTRONIX ENSTAB -Workshop 1 : IR Sensor -Copy and Paste this code on your Arduino IDE - - -This code is delicately typed by the ELECTRONIX Club for whom this may be of concern -HEDFI Wassim. -*/ - - -#include - -#define DEBUG_ENABLE // Comment this line before putting the code in the robot to remove serial printing - // otherwise may slow down the performance of your robot - -#ifdef DEBUG_ENABLE - #define DEBUG_MACRO(STRING) Serial.println(STRING) -#else - #define DEBUG_MACRO(STRING) // DO Nothing -#endif - - -#define ENABLE_1_PIN 10 // same as we did in the previous workshop (3) -#define MOTOR_1_INPUT_1 9 -#define MOTOR_1_INPUT_2 8 -#define MOTOR_2_INPUT_1 7 -#define MOTOR_2_INPUT_2 6 -#define ENABLE_2_PIN 5 - -#define SERIAL_RX_PIN 0 // Connected to the Blutooth module's TX -#define SERIAL_TX_PIN 1 // Connected to the Blutooth module's RX ; don't forget the voltage divider ! - - - -#define MAX_MOTOR_SPEED 255 -#define NORMAL_MOTOR_SPEED 150 -#define SLOW_MOTOR_SPEED 80 - -// Software serial instance -SoftwareSerial bluetoothSerial(SERIAL_RX_PIN, SERIAL_TX_PIN); // RX_PIN, TX_PIN -char incomingData = 'r'; - -/* Functions prototypes */ -void forward(uint8_t speed); -void reverse(uint8_t speed); -void right(uint8_t speed); -void left(uint8_t speed); -void sharpRightTurn(uint8_t speed); -void sharpLeftTurn(uint8_t speed); -void stopBot(uint8_t speed); -void scanBluetooth(); - -/* ---------------------------------------------------------- */ -void setup() { - #ifdef DEBUG_ENABLE - Serial.begin(9600); - #endif - - bluetoothSerial.begin(9600); // This is the serial port we'll communicate with the bluetooth module through - DEBUG_MACRO("--- Bluetooth RC robot started ---"); - - pinMode(MOTOR_1_INPUT_1, OUTPUT); - pinMode(MOTOR_1_INPUT_2, OUTPUT); - pinMode(MOTOR_2_INPUT_1, OUTPUT); - pinMode(MOTOR_2_INPUT_2, OUTPUT); - pinMode(ENABLE_1_PIN, OUTPUT); - pinMode(ENABLE_2_PIN, OUTPUT); -} - -void loop() { - scanBluetooth(); // Check if there's any incoming data through bluetooth - - switch(incomingData){ // Choose appropriate action - case 'S': - stopBot(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("STOPPING"); - break; - - case 'F': - forward(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("FORWARD"); - break; - - case 'L': - sharpLeftTurn(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("LEFT"); - break; - - case 'R': - sharpRightTurn(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("RIGHT"); - break; - - case 'B': - reverse(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("REVERSE"); - break; - - default: - DEBUG_MACRO("UNKNOWN COMMAND"); - break; - } -/* - forward(100); - delay(1500); - sharpRightTurn(100); - delay(1500); - sharpLeftTurn(100); - delay(1500); - reverse(100); - delay(1500);*/ -} -/* ---------------------------------------------------------- */ - -void forward(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} - -void reverse(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, HIGH); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, HIGH); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void right(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void left(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} - -void sharpRightTurn(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, HIGH); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void sharpLeftTurn(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, HIGH); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} - -void stopBot(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void scanBluetooth(){ - // There's data in the serial buffer (available() returns the number of bytes available) - if(bluetoothSerial.available() > 0) incomingData = bluetoothSerial.read(); // Read a byte - else Serial.println(incomingData); -} diff --git a/Robothon/IR_workshop1/IR_workshop1.ino b/Robothon/IR_workshop1/IR_workshop1.ino deleted file mode 100644 index c61d1e7..0000000 --- a/Robothon/IR_workshop1/IR_workshop1.ino +++ /dev/null @@ -1,28 +0,0 @@ -/* -ROBOTHON ELECTRONIX ENSTAB -Workshop 1 : IR Sensor -Copy and Paste this code on your Arduino IDE - - -This code is delicately typed by the ELECTRONIX Club for whom this may be of concern -HEDFI Wassim. -*/ - - -#define sensor 9 // Call the sensor's output pin(9) as sensor, this will help when you need to change the pin, for any reason - // if you want to change the pin number you want have to do so for all the code (wherever you used the pin 9), but just change it here - // you want to call the sensor pin in the code ? just type sensor ! -int sensorValue ; // Create an empty variable to store the sonsor's reading - -void setup() { - -pinMode(sensor,INPUT); // Set the pin 'sensor'(9) to INPUT Mode; our Arduino will receive data from the sensor, hence this pin should be input -Serial.begin(9600); // This will set the our Arduino to cmmunicate with the Serial Monitor of the Arduino IDE with a bandwidth of 9600 -} - -void loop() { - // put your main code here, to run repeatedly: -sensorValue=digitalRead(sensor); // the function "digitalRead" reads the value on the pin 'sensor'(9) and return a value of 0 or 1 -Serial.println(sensorValue); // The function 'Serial.println' will write the value on the Serial Monitor - -} diff --git a/Robothon/RC_workshop4/RC_workshop4.ino b/Robothon/RC_workshop4/RC_workshop4.ino deleted file mode 100644 index 9598493..0000000 --- a/Robothon/RC_workshop4/RC_workshop4.ino +++ /dev/null @@ -1,190 +0,0 @@ -/* -ROBOTHON ELECTRONIX ENSTAB -Workshop 1 : IR Sensor -Copy and Paste this code on your Arduino IDE - - -This code is delicately typed by the ELECTRONIX Club for whom this may be of concern -HEDFI Wassim. -*/ - - -#include - -#define DEBUG_ENABLE // Comment this line before putting the code in the robot to remove serial printing - // otherwise may slow down the performance of your robot - -#ifdef DEBUG_ENABLE - #define DEBUG_MACRO(STRING) Serial.println(STRING) -#else - #define DEBUG_MACRO(STRING) // DO Nothing -#endif - - -#define ENABLE_1_PIN 10 // same as we did in the previous workshop (3) -#define MOTOR_1_INPUT_1 9 -#define MOTOR_1_INPUT_2 8 -#define MOTOR_2_INPUT_1 7 -#define MOTOR_2_INPUT_2 6 -#define ENABLE_2_PIN 5 - -#define SERIAL_RX_PIN 0 // Connected to the Blutooth module's TX -#define SERIAL_TX_PIN 1 // Connected to the Blutooth module's RX ; don't forget the voltage divider ! - - - -#define MAX_MOTOR_SPEED 255 -#define NORMAL_MOTOR_SPEED 150 -#define SLOW_MOTOR_SPEED 80 - -// Software serial instance -SoftwareSerial bluetoothSerial(SERIAL_RX_PIN, SERIAL_TX_PIN); // RX_PIN, TX_PIN -char incomingData = 'r'; - -/* Functions prototypes */ -void forward(uint8_t speed); -void reverse(uint8_t speed); -void right(uint8_t speed); -void left(uint8_t speed); -void sharpRightTurn(uint8_t speed); -void sharpLeftTurn(uint8_t speed); -void stopBot(uint8_t speed); -void scanBluetooth(); - -/* ---------------------------------------------------------- */ -void setup() { - #ifdef DEBUG_ENABLE - Serial.begin(9600); - #endif - - bluetoothSerial.begin(9600); // This is the serial port we'll communicate with the bluetooth module through - DEBUG_MACRO("--- Bluetooth RC robot started ---"); - - pinMode(MOTOR_1_INPUT_1, OUTPUT); - pinMode(MOTOR_1_INPUT_2, OUTPUT); - pinMode(MOTOR_2_INPUT_1, OUTPUT); - pinMode(MOTOR_2_INPUT_2, OUTPUT); - pinMode(ENABLE_1_PIN, OUTPUT); - pinMode(ENABLE_2_PIN, OUTPUT); -} - -void loop() { - scanBluetooth(); // Check if there's any incoming data through bluetooth - - switch(incomingData){ // Choose appropriate action - case 'S': - stopBot(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("STOPPING"); - break; - - case 'F': - forward(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("FORWARD"); - break; - - case 'L': - sharpLeftTurn(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("LEFT"); - break; - - case 'R': - sharpRightTurn(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("RIGHT"); - break; - - case 'B': - reverse(NORMAL_MOTOR_SPEED); - DEBUG_MACRO("REVERSE"); - break; - - default: - DEBUG_MACRO("UNKNOWN COMMAND"); - break; - } -/* - forward(100); - delay(1500); - sharpRightTurn(100); - delay(1500); - sharpLeftTurn(100); - delay(1500); - reverse(100); - delay(1500);*/ -} -/* ---------------------------------------------------------- */ - -void forward(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} - -void reverse(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, HIGH); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, HIGH); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void right(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void left(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} - -void sharpRightTurn(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, HIGH); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void sharpLeftTurn(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, HIGH); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} - -void stopBot(uint8_t speed){ - /* The pin numbers and high, low values might be different depending on your connections */ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void scanBluetooth(){ - // There's data in the serial buffer (available() returns the number of bytes available) - if(bluetoothSerial.available() > 0) incomingData = bluetoothSerial.read(); // Read a byte - else Serial.println(incomingData); -} diff --git a/Robothon/US_workshop2/US_workshop2.ino b/Robothon/US_workshop2/US_workshop2.ino deleted file mode 100644 index 5da777c..0000000 --- a/Robothon/US_workshop2/US_workshop2.ino +++ /dev/null @@ -1,43 +0,0 @@ -/* -ROBOTHON ELECTRONIX ENSTAB -Workshop 2 : Ultrasonic Sensor -Copy and Paste this code on your Arduino IDE - - -This code is delicately typed by the ELECTRONIX Club for whom this may be of concern -HEDFI Wassim. -*/ - - -#define echoPin A3 // attacher echo du capteur ultrason a la pin A3 de la carte -#define trigPin A2 // attacher trig du capteur ultrason a la pin A2 de la carte - -void setup() { - // put your setup code here, to run once: - pinMode(echoPin, INPUT); // echopin is an input for the Arduino board - pinMode(trigPin,OUTPUT); - Serial.begin(9600); // you saw this before ;) - -} - -void loop() { - // put your main code here, to run repeatedly: -//***calcul de distance à l'aide du capteur ultrason - - digitalWrite(trigPin, LOW); // initialize the trigger at 0 (LOW) - delayMicroseconds(2); // keep it at zero for 2ms - digitalWrite(trigPin, HIGH); // send a pulse (HIGH) on the trigger - delayMicroseconds(10); // send the high pulse for 10ms - digitalWrite(trigPin, LOW); // put it back at zero - - float duration = pulseIn(echoPin, HIGH); // the function 'pulsin' acts as a chronometer - // when you call it it will start counting time and stop when echoPin is high and returns the duration - // Calculating the distance - float distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (from the sensor to the object and back == double the distance we want to calculate) - float distanceCentimeter; // create a variable to store the distance - if (distance>200) distanceCentimeter = 200; // ultrasonic sensor will give faulty measures for distances over 200cm, so the max distance we will define is 200cm - else distanceCentimeter= distance; - - Serial.println(distanceCentimeter); // print the distance on the Seiral monitor - delay(500); // make a little delay to not saturate the monitor -} diff --git a/Robothon/l298n_workshop3/l298n_workshop3.ino b/Robothon/l298n_workshop3/l298n_workshop3.ino deleted file mode 100644 index 1cae227..0000000 --- a/Robothon/l298n_workshop3/l298n_workshop3.ino +++ /dev/null @@ -1,109 +0,0 @@ -/* -ROBOTHON ELECTRONIX ENSTAB -Workshop 2 : Ultrasonic Sensor -Copy and Paste this code on your Arduino IDE - - -This code is delicately typed by the ELECTRONIX Club for whom this may be of concern -HEDFI Wassim. -*/ - - - -#define ENABLE_1_PIN 10 // This should be a pwm (~) pin -#define MOTOR_1_INPUT_1 9 -#define MOTOR_1_INPUT_2 8 -#define MOTOR_2_INPUT_1 7 -#define MOTOR_2_INPUT_2 6 -#define ENABLE_2_PIN 5 // This should be a pwm (~) pin - - - - -#define MAX_MOTOR_SPEED 200 -#define SLOW_MOTOR_SPEED 80 -#define NORMAL_MOTOR_SPEED 100 - - - -void setup() { - pinMode(MOTOR_1_INPUT_1, OUTPUT); // DEFINE - pinMode(MOTOR_1_INPUT_2, OUTPUT); // MOTOR - pinMode(MOTOR_2_INPUT_1, OUTPUT); // DRIVER - pinMode(MOTOR_2_INPUT_2, OUTPUT); // PINS - pinMode(ENABLE_1_PIN, OUTPUT); // AS - pinMode(ENABLE_2_PIN, OUTPUT); // OUTPUT -} - -void forward(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} - -void reverse(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, HIGH); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, HIGH); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void sharpleft(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, HIGH); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} -void left(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, HIGH); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - -void sharpright(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, HIGH); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} -void right(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, HIGH); -} -void stopBot(uint8_t speed){ - analogWrite(ENABLE_1_PIN, speed); //Left Motor Speed - analogWrite(ENABLE_2_PIN, speed); //Right Motor Speed - digitalWrite(MOTOR_1_INPUT_1, LOW); - digitalWrite(MOTOR_1_INPUT_2, LOW); - digitalWrite(MOTOR_2_INPUT_1, LOW); - digitalWrite(MOTOR_2_INPUT_2, LOW); -} - - - -void loop() { -forward(NORMAL_MOTOR_SPEED); -delay(2000); -sharpright(NORMAL_MOTOR_SPEED); -delay(2000); -sharpleft(NORMAL_MOTOR_SPEED); -delay(2000); -reverse(NORMAL_MOTOR_SPEED); -delay(2000); -} \ No newline at end of file