De schema's van de motorschakeling:
Hier kan je zien hoe schakeling is opgebouwd.
Hier kan je zien hoe de arduino is geschakeld met de verschillende elementen.
Arduino programma:
int noodstop = 13;
int links = 11;
int rechts = 12;
int linksmotor = 2;
int rechtsmotor = 3;
int ventilator = 4;
int ak = 0 ;
int ac = 0;
int snelheid = 10;
int pedaal = A0;
int waarde = 0;
int drukknopnoodstop = 0;
int drukknopLinks = 0;
int drukknopRechts = 0;
void setup() {
// put your setup code here, to run once:
pinMode(links, INPUT);
pinMode(rechts, INPUT);
pinMode(noodstop, INPUT);
pinMode(linksmotor, OUTPUT);
pinMode(rechtsmotor, OUTPUT);
pinMode(snelheid, OUTPUT);
pinMode(ventilator, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
drukknopLinks = digitalRead(links);
drukknopRechts = digitalRead(rechts);
drukknopnoodstop = digitalRead(noodstop);
if (drukknopLinks > 0)
{
digitalWrite(linksmotor, HIGH);
digitalWrite(rechtsmotor, LOW);
digitalWrite(ventilator, HIGH);
waarde = analogRead(pedaal);
if ((waarde <= 200) || (drukknopnoodstop > 0))
{
digitalWrite(snelheid, HIGH);
ak = 0;
}
else if (waarde > 200)
{
if (ak <30){
digitalWrite(snelheid, LOW);
delay(ak);
digitalWrite(snelheid, HIGH);
delay(25);
ak = (ak+ 1);
}
else {
digitalWrite(snelheid, LOW);
}
}
}
else if (drukknopRechts > 0)
{
digitalWrite(linksmotor, LOW);
digitalWrite(rechtsmotor, HIGH);
digitalWrite(ventilator, HIGH);
waarde = analogRead(pedaal);
if ((waarde <= 200) or (drukknopnoodstop > 0))
{
digitalWrite(snelheid, HIGH);
ac = 0;
}
else if (waarde > 200)
{
if (ac <30){
digitalWrite(snelheid, LOW);
delay(ac
);
digitalWrite(snelheid, HIGH);
delay(25);
ac = (ac+ 1);
}
else {
digitalWrite(snelheid, LOW);
}
}
}
else
{
digitalWrite(linksmotor, LOW);
digitalWrite(rechtsmotor, LOW);
digitalWrite(ventilator, LOW);
}
}
Arduino programma:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
unsigned long testtijd;
unsigned long tijdverschil;
unsigned long reken;
unsigned long bew;
unsigned long tijdverschilB;
int sensor = 13;
int lusA = 0;
int lusC = 0;
void setup() {
lcd.begin(16, 1);
pinMode(sensor,INPUT); // put your setup code here, to run once:
}
void loop() {
if ((digitalRead(sensor) == 0) and (lusC == 0)){
unsigned long testtijd = millis();
bew = (testtijd*1);
lusA = 0;
lusC == lusC++;
}
else if((digitalRead(sensor) ==0)and (lusC != 0)){
unsigned long tijdNuB = millis();
tijdverschilB = (tijdNuB - (bew));
if (tijdverschilB > 4800){
lcd.setCursor(0, 0);
lcd.print("0");
lcd.setCursor(2, 0);
Serial.println(tijdverschilB);
lcd.print("km/h");
}
if ((digitalRead(sensor) ==1) and (lusA ==0)){
unsigned long tijdNu = millis();
lcd.setCursor(0, 0);
lcd.print(" km/h");
tijdverschil = (tijdNu - (bew));
lcd.setCursor(0, 0);
reken = (((3.14*420)/tijdverschil)*3.6);
lusC = 0;
lcd.print(reken);
lcd.setCursor(2, 0);
lcd.print("km/h");
lusA == lusA++;
}
//snelheid berekenen
else if((digitalRead(sensor) == 1)and (lusA > 0)){
}
}
}
Geen opmerkingen:
Een reactie posten