LoginSignup
1
1

More than 5 years have passed since last update.

arduinoでインスツルメント パネル テスター

Last updated at Posted at 2016-05-17

概要

ベネリ アディバと言う、屋根付きスクーターのインスツルメント パネルをarduino unoでテストしてみた。
パルスは、一回転6発。
タイヤは、120/70-13なので、円周1.56mなのだが、ずれる。
1.66mの様だ。

動画

写真

MVC-002S.JPG

回路図

simu3.JPG

回路図

test3.JPG

サンプルコード

#include <Lcd4567.h>
#include <TimerOne.h>

Lcd4567 lcd;
volatile int rpm = 20;
volatile int span = 100;
void fire()
{
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    delayMicroseconds(span);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
}
void setrev(int rpm)
{
    long us = 990000 / rpm;
    span = us / 4;
    Timer1.initialize(us);
    Timer1.start();
}
void setup()
{
    pinMode(9, OUTPUT);
    digitalWrite(9, HIGH);
    pinMode(8, OUTPUT);
    digitalWrite(8, HIGH);
    lcd = Lcd4567();
    lcd.begin(20, 4);
    lcd.setCursor(0, 0);
    lcd.print("benelli simu3");
    lcd.setCursor(0, 1);
    lcd.print("set km/h");
    lcd.setCursor(0, 2);
    lcd.print("read vol");
    lcd.setCursor(0, 3);
    lcd.print("ok");
    Timer1.initialize(100);
    Timer1.attachInterrupt(fire);
}
void loop()
{
    int val;
    lcd.setCursor(15, 1);
    lcd.print("    ");
    lcd.setCursor(15, 2);
    lcd.print("    ");
    delay(100);
    val = analogRead(A0);
    rpm = map(val, 0, 1023, 0, 120);
    setrev(rpm);
    lcd.setCursor(15, 1);
    lcd.print(rpm);
    lcd.setCursor(15, 2);
    lcd.print(val);
    delay(500);
}

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1