是否可以通过Arduino的模拟输出控制两个7段显示器?
我在和arduino一起玩,我在努力制造东西。 在为我的项目添加越来越多的内容时,我发现了一些困难。由于我的LCD,我的数字管脚用完了,我想控制2个7 seg显示器,从温度传感器投射一些数字 我创建此示意图是为了向您展示我的位置:是否可以通过Arduino的模拟输出控制两个7段显示器?,arduino,multiplexing,Arduino,Multiplexing,我在和arduino一起玩,我在努力制造东西。 在为我的项目添加越来越多的内容时,我发现了一些困难。由于我的LCD,我的数字管脚用完了,我想控制2个7 seg显示器,从温度传感器投射一些数字 我创建此示意图是为了向您展示我的位置: //包括库代码: #包括 //使用接口引脚的编号初始化库 液晶液晶显示器(12,11,10,8,7,4); //温度引脚 const int类比素=A1; int-RawValue=0; 双电压=0; 双tempC=0; 双tempF=0; //LDR引脚 int
//包括库代码:
#包括
//使用接口引脚的编号初始化库
液晶液晶显示器(12,11,10,8,7,4);
//温度引脚
const int类比素=A1;
int-RawValue=0;
双电压=0;
双tempC=0;
双tempF=0;
//LDR引脚
int LDR_传感器=A0;
int LDR_值=0;
//阵列以保存七个Seg引脚的数字配置
int num_数组[10][7]={{1,1,1,1,1,0},//0
{ 0,1,1,0,0,0,0 }, // 1
{ 1,1,0,1,1,0,1 }, // 2
{ 1,1,1,1,0,0,1 }, // 3
{ 0,1,1,0,0,1,1 }, // 4
{ 1,0,1,1,0,1,1 }, // 5
{ 1,0,1,1,1,1,1 }, // 6
{ 1,1,1,0,0,0,0 }, // 7
{ 1,1,1,1,1,1,1 }, // 8
{ 1,1,1,0,0,1,1 }}; // 9
int第一位数字=0;
整数第二位=0;
//函数头
void Num_Write(int);
无效设置(){
Serial.begin(9600);
//设置LCD的列数和行数:
//lcd.begin(16,2);
//lcd.clear();
//延迟(2000年);
//设置pin模式
------------这里我应该放置多路复用器的模拟引脚
}
void循环(){
//将光标设置为第0列第1行
//(注意:第1行是第二行,因为计数从0开始):
//lcd.setCursor(0,1);
//读取温度传感器的值
RawValue=模拟读取(模拟输入);
电压=(原始值/1023.0)*5000;//5000以获得毫伏。
tempC=(电压-500)*0.1;//500是偏移量
//串行打印值以进行调试
Serial.print(“Raw Value=”);//显示预缩放值
串行打印(原始值);
Serial.print(“\t毫伏=”);//显示测量的电压
串行打印(电压,0)//
Serial.print(“\t温度在C=”);
序列号println(tempC);
Serial.println(int(tempC));
第一位数字=int(tempC)/10;
Serial.print(“第一个数字是:”);
Serial.print(第一位);//获取七段显示的第一个数字
第二位=int(tempC)-(第一位*10);
Serial.print(“\t第二位数字为:”);
Serial.println(第二位);
Serial.println(“\n”);
//读取LDR传感器的值
LDR_值=模拟读数(LDR_传感器);
//将值打印到LCD屏幕
//lcd.setCursor(0,0);
//打印(“LDR的值为:”);
//lcd.setCursor(0,1);
//lcd.打印(LDR_值);
延迟(5000);
//lcd.打印(“”);
}
所以我的问题是,是否可以在7seg显示器上输出两个不同的数字(第一个数字和第二个数字)。我从中得到了一些想法。我认为原理图还可以。一些SIPO移位寄存器不是工作得更好吗?你正在驾驶的东西看起来不需要很快的刷新速度。LCD使用6个数字管脚,如果我没记错的话,移位寄存器使用4个。即使使用PWM,仍应留有足够的引脚。我已经从快速浏览中看到了74HC595。为什么不菊花链另一个呢?一个PCF8574模块(I2C总线的8位I/O扩展器),然后你通过i2cA与LCD对话。与真实的电路图相比,熔块图很难阅读,如果它显然不适合你的草图(草图中图片的rgb led在哪里?),我不想看得更近一些。在你的链接中,他们显然使用了两个菊花链'595寄存器。难道一些SIPO移位寄存器不能更好地工作吗?你正在驾驶的东西看起来不需要很快的刷新速度。LCD使用6个数字管脚,如果我没记错的话,移位寄存器使用4个。即使使用PWM,仍应留有足够的引脚。我已经从快速浏览中看到了74HC595。为什么不菊花链另一个呢?一个PCF8574模块(I2C总线的8位I/O扩展器),然后你通过i2cA与LCD对话。与真实的电路图相比,熔块图很难阅读,如果它显然不适合你的草图(草图中图片的rgb led在哪里?),我不想看得更近一些。在你的链接中,他们显然使用了两个菊花链'595寄存器
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 8, 7, 4);
// Temperature Pins
const int analogIn = A1;
int RawValue= 0;
double Voltage = 0;
double tempC = 0;
double tempF = 0;
//LDR Pins
int LDR_sensor = A0;
int LDR_value = 0;
//array to save Seven Seg pin configuration of numbers
int num_array[10][7] = { { 1,1,1,1,1,1,0 }, // 0
{ 0,1,1,0,0,0,0 }, // 1
{ 1,1,0,1,1,0,1 }, // 2
{ 1,1,1,1,0,0,1 }, // 3
{ 0,1,1,0,0,1,1 }, // 4
{ 1,0,1,1,0,1,1 }, // 5
{ 1,0,1,1,1,1,1 }, // 6
{ 1,1,1,0,0,0,0 }, // 7
{ 1,1,1,1,1,1,1 }, // 8
{ 1,1,1,0,0,1,1 }}; // 9
int first_digit = 0 ;
int second_digit = 0 ;
//function header
void Num_Write(int);
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
// lcd.begin(16, 2);
// lcd.clear();
// delay(2000);
// set pin modes
------------Here i should place the analog pins for the multiplexer
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
// lcd.setCursor(0, 1);
//Read values for the temperature sensor
RawValue = analogRead(analogIn);
Voltage = (RawValue / 1023.0) * 5000; // 5000 to get millivots.
tempC = (Voltage-500) * 0.1; // 500 is the offset
// Serial print the values for debug purposes
Serial.print("Raw Value = " ); // shows pre-scaled value
Serial.print(RawValue);
Serial.print("\t milli volts = "); // shows the voltage measured
Serial.print(Voltage,0); //
Serial.print("\t Temperature in C = ");
Serial.println(tempC);
Serial.println(int(tempC));
first_digit = int(tempC) / 10 ;
Serial.print("The first digit is : " );
Serial.print(first_digit); // Get the first number for the seven seg display
second_digit = int(tempC) - (first_digit * 10) ;
Serial.print("\tThe second digit is : ");
Serial.println(second_digit);
Serial.println("\n");
// Read values for the LDR sensor
LDR_value = analogRead(LDR_sensor);
//Print values to the LCD screen
// lcd.setCursor(0, 0);
// lcd.print("The value of LDR is :");
// lcd.setCursor(0, 1);
// lcd.print(LDR_value) ;
delay(5000);
// lcd.print("") ;
}