步骤1:零件清单
R1 = 10至220Ω½W取决于首选的LED亮度
R2,R3 = 10ΚΩ¼W
Arduino Uno
霍尔传感器
7805 5V稳压器TO-220
C1,C2 = 220 uf
7段LED显示屏(共阳极)
9-12 v电池(否则连接设备
连接电线,通用PCB。
步骤2:工作原理
主要工作原理基于AVR Arduino UNO。
读取两个霍尔传感器和空档开关的信号,并将当前档位输出到7段LED指示器,通过
在最大输出功率下,传感器和传感器产生的热量很大。或出于这个原因,我们将其直接安装在接地层上以实现最大的散热。
步骤3:电路图
int ledPinA = 13; // LED connected to digital pin 3
int ledPinB = 12; // LED connected to digital pin 4
int ledPinC = 11; // LED connected to digital pin 5
int ledPinD = 10; // LED connected to digital pin 6
int ledPinE = 9; // LED connected to digital pin 7
int ledPinF = 8; // LED connected to digital pin 8
int ledPinG = 7; // LED connected to digital pin 9
#define BUTTON_DOWN 4
#define BUTTON_UP 6
步骤4:源代码
#define BUTTON_DOWN 4
#define BUTTON_UP 6
int ledPinA = 13; // LED connected to digital pin 3
int ledPinB = 12; // LED connected to digital pin 4
int ledPinC = 11; // LED connected to digital pin 5
int ledPinD = 10; // LED connected to digital pin 6
int ledPinE = 9; // LED connected to digital pin 7
int ledPinF = 8; // LED connected to digital pin 8
int ledPinG = 7; // LED connected to digital pin 9
int val_down = 0;
int old_val_down = 0;
int val_up = 0;
int old_val_up = 0;
int state = 0;
int gear = 0;
// The setup() method runs once, when the sketch starts
void setup()
{
pinMode(BUTTON_DOWN, INPUT);
pinMode(BUTTON_UP, INPUT);
// initialize the digital pin as an output:
pinMode(ledPinA, OUTPUT);
pinMode(ledPinB, OUTPUT);
pinMode(ledPinC, OUTPUT);
pinMode(ledPinD, OUTPUT);
pinMode(ledPinE, OUTPUT);
pinMode(ledPinF, OUTPUT);
pinMode(ledPinG, OUTPUT);
}
void led0()
{
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, LOW);
digitalWrite(ledPinD, LOW);
digitalWrite(ledPinE, LOW);
digitalWrite(ledPinF, LOW);
digitalWrite(ledPinG, HIGH);
}
void led1()
{
digitalWrite(ledPinA, HIGH);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, LOW);
digitalWrite(ledPinD, HIGH);
digitalWrite(ledPinE, HIGH);
digitalWrite(ledPinF, HIGH);
digitalWrite(ledPinG, HIGH);
}
void led2()
{
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, HIGH);
digitalWrite(ledPinD, LOW);
digitalWrite(ledPinE, LOW);
digitalWrite(ledPinF, HIGH);
digitalWrite(ledPinG, LOW);
}
void led3()
{
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, LOW);
digitalWrite(ledPinD, LOW);
digitalWrite(ledPinE, HIGH);
digitalWrite(ledPinF, HIGH);
digitalWrite(ledPinG, LOW);
}
void led4()
{
digitalWrite(ledPinA, HIGH);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, LOW);
digitalWrite(ledPinD, HIGH);
digitalWrite(ledPinE, HIGH);
digitalWrite(ledPinF, LOW);
digitalWrite(ledPinG, LOW);
}
void led5()
{
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, HIGH);
digitalWrite(ledPinC, LOW);
digitalWrite(ledPinD, LOW);
digitalWrite(ledPinE, HIGH);
digitalWrite(ledPinF, LOW);
digitalWrite(ledPinG, LOW);
}
void led6()
{
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, HIGH);
digitalWrite(ledPinC, LOW);
digitalWrite(ledPinD, LOW);
digitalWrite(ledPinE, LOW);
digitalWrite(ledPinF, LOW);
digitalWrite(ledPinG, LOW);
}
void led7()
{
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, LOW);
digitalWrite(ledPinD, HIGH);
digitalWrite(ledPinE, HIGH);
digitalWrite(ledPinF, HIGH);
digitalWrite(ledPinG, HIGH);
}
void led8()
{
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, LOW);
digitalWrite(ledPinD, LOW);
digitalWrite(ledPinE, LOW);
digitalWrite(ledPinF, LOW);
digitalWrite(ledPinG, LOW);
}
void led9()
{
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, LOW);
digitalWrite(ledPinD, LOW);
digitalWrite(ledPinE, HIGH);
digitalWrite(ledPinF, LOW);
digitalWrite(ledPinG, LOW);
}
void setLed(int number)
{
switch (number) {
case 0:
led0();
break;
case 1:
led1();
break;
case 2:
led2();
break;
case 3:
led3();
break;
case 4:
led4();
break;
case 5:
led5();
break;
case 6:
led6();
break;
case 7:
led7();
break;
case 8:
led8();
break;
case 9:
led9();
break;
}
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void oldloop()
{
// wait for a second
led0();
delay(1000); // wait for a second
led1();
delay(1000); // wait for a second
led2();
delay(1000); // wait for a second
led3();
delay(1000); // wait for a second
led4();
delay(1000); // wait for a second
led5();
delay(1000); // wait for a second
led6();
delay(1000); // wait for a second
led7();
delay(1000); // wait for a second
led8();
delay(1000); // wait for a second
led9();
delay(1000); // wait for a second
}
void loop()
{
val_up = digitalRead(BUTTON_UP);
if ((val_up == HIGH) && (old_val_up == LOW)&&gear《7 ) {
gear += 1;
delay(100);
}
old_val_up = val_up;
val_down = digitalRead(BUTTON_DOWN);
if ((val_down == HIGH) && (old_val_down == LOW)&&gear》1 ){
gear -= 1;
delay(100);
}
else if ((val_down == HIGH) && (old_val_down == LOW)&&(gear《1))
{
gear += 1;
delay(100);
}
else if ((val_down == HIGH) && (old_val_down == LOW)){
gear += -1;
delay(100);
}
old_val_down = val_down;
if (gear 》= 6) {
gear = 6;
}
setLed(gear);
}
第5步:安装
将所有电路组装在一起后,电路便可以正常工作并可以安装在摩托车上了。
在我的照片中,我将这种指示器用于基于杜克自行车发动机的汽车
因此自行车的安装技术类似。..
注意:齿轮机构与自行车相同。
责任编辑:wv
-
指示器
+关注
关注
0文章
251浏览量
38282
发布评论请先 登录
相关推荐
评论