code
This commit is contained in:
parent
09511f09ab
commit
764876406f
BIN
electronics/circuit.fzz
Normal file
BIN
electronics/circuit.fzz
Normal file
Binary file not shown.
5
firmware/robot-v2/.vscode/arduino.json
vendored
Normal file
5
firmware/robot-v2/.vscode/arduino.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"board": "arduino:avr:nano",
|
||||
"configuration": "cpu=atmega328old",
|
||||
"port": "/dev/ttyUSB0"
|
||||
}
|
19
firmware/robot-v2/.vscode/c_cpp_properties.json
vendored
Normal file
19
firmware/robot-v2/.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"/home/gnieark/arduino-1.8.8/tools/**",
|
||||
"/home/gnieark/arduino-1.8.8/hardware/arduino/avr/**"
|
||||
],
|
||||
"forcedInclude": [
|
||||
"/home/gnieark/arduino-1.8.8/hardware/arduino/avr/cores/arduino/Arduino.h"
|
||||
],
|
||||
"intelliSenseMode": "gcc-x64",
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "gnu++14"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
60
firmware/robot-v2/robot-v2.ino
Normal file
60
firmware/robot-v2/robot-v2.ino
Normal file
|
@ -0,0 +1,60 @@
|
|||
|
||||
int motor1_enablePin = 10; //pwm
|
||||
int motor1_in1Pin = 3;
|
||||
int motor1_in2Pin = 2;
|
||||
|
||||
int motor2_enablePin = 11;//pwm
|
||||
int motor2_in1Pin = 5;
|
||||
int motor2_in2Pin = 6;
|
||||
|
||||
|
||||
//Fonction qui set le moteur1
|
||||
void SetMotor1(int speed, boolean reverse)
|
||||
{
|
||||
analogWrite(motor1_enablePin, speed);
|
||||
digitalWrite(motor1_in1Pin, ! reverse);
|
||||
digitalWrite(motor1_in2Pin, reverse);
|
||||
}
|
||||
|
||||
//Fonction qui set le moteur2
|
||||
void SetMotor2(int speed, boolean reverse)
|
||||
{
|
||||
analogWrite(motor2_enablePin, speed);
|
||||
digitalWrite(motor2_in1Pin, ! reverse);
|
||||
digitalWrite(motor2_in2Pin, reverse);
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
pinMode(motor1_in1Pin, OUTPUT);
|
||||
pinMode(motor1_in2Pin, OUTPUT);
|
||||
pinMode(motor1_enablePin, OUTPUT);
|
||||
pinMode(motor2_in1Pin, OUTPUT);
|
||||
pinMode(motor2_in2Pin, OUTPUT);
|
||||
pinMode(motor2_enablePin, OUTPUT);
|
||||
}
|
||||
|
||||
|
||||
void loop(){
|
||||
for(int i = 50; i < 255; i++){
|
||||
SetMotor1(i, true);
|
||||
delay(100);
|
||||
}
|
||||
for(int i = 50; i < 255; i++){
|
||||
SetMotor1(i, false);
|
||||
delay(100);
|
||||
}
|
||||
SetMotor1(0, true);
|
||||
for(int i = 50; i < 255; i++){
|
||||
SetMotor2(i, true);
|
||||
delay(100);
|
||||
}
|
||||
for(int i = 50; i < 255; i++){
|
||||
SetMotor2(i, false);
|
||||
delay(100);
|
||||
}
|
||||
SetMotor2(0, true);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user