This commit is contained in:
Gnieark 2020-09-28 23:02:14 +02:00
parent 09511f09ab
commit 764876406f
4 changed files with 84 additions and 0 deletions

BIN
electronics/circuit.fzz Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
{
"board": "arduino:avr:nano",
"configuration": "cpu=atmega328old",
"port": "/dev/ttyUSB0"
}

View 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
}

View 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);
}