hallo, we komen er nogsteeds niet uit nu hebben we besloten om eerste even een code te maken die de pulsen telt. Hoe werken we dit uit naar km/H
#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int reedSensorPin = 4;
const int contrastValue = 200;
unsigned long startTime = 0;
unsigned long elapsedTime = 0;
unsigned long lastActivityTime = 0;
int count = 0;
int aantal = 0;
bool counting = false;
int state = 0;
void startCounting();
void stopCounting();
void setup() {
lcd.init();
lcd.backlight();
lcd.setContrast(contrastValue);
lcd.setCursor(0,0);
lcd.print("Ready");
pinMode(reedSensorPin, INPUT_PULLUP);
lcd.setCursor(0,0);
lcd.print("count: ");
lcd.print(count);
}
void loop() {
if (digitalRead(reedSensorPin) == LOW && state == 1)
{
state = 0;
//count = 0;
count++;
lcd.setCursor(7,0);
count++;
lcd.print(count);
delay(10);
/*
if (count > 0) {
count = +0;
}
*/
}
if (digitalRead(reedSensorPin) == HIGH && state == 0)
{
state = 1;
//count = +1;
delay(10);
}
switch(state)
{
case 0:
{
break;
}
case 1:
{
break;
}
default:
{
break;
}
}
}
void startCounting() {
startTime = millis();
count = 0;
}
void stopCounting() {
elapsedTime = millis() - startTime;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Elapsed Time: ");
lcd.print(elapsedTime /1000);
lcd.setCursor(0, 1);
lcd.print("Snelheid:");
lcd.print(count /100);
}