Помогите разобраться с выводом на светодиодную матрицу HCMS-2975
- Войдите на сайт для отправки комментариев
Сб, 02/05/2015 - 21:25
Помогите разобраться с выводом на светодиодную матрицу HCMS-2975
Вот такой скетч не работает, выводится на экран: "DC VOLTMETER"
#include <font5x7.h>
#include <LedDisplay.h>
#define dataPin 2 // connects to the display's data in
#define registerSelect 3 // the display's register select pin
#define clockPin 4 // the display's clock pin
#define enable 5 // the display's chip enable pin
#define reset 6 // the display's reset pin
#define displayLength 16 // number of characters in the display
LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin, enable, reset, displayLength);
int analogInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000.0; // сопротивление R1 (100K)
float R2 = 10000.0; // сопротивление R2 (10K)
int value = 0;
void setup(){
pinMode(analogInput, INPUT);
myDisplay.begin();
myDisplay.home();
myDisplay.print("DC VOLTMETER");
}
void loop(){
// считывание аналогового значения
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
if (vin<0.09) {
vin=0.0;// обнуляем нежелательное значение
}
myDisplay.home();
myDisplay.print("INPUT V= ");
myDisplay.print(vin);
delay(500);
}А обрезанная версия без проверок выводит сырое значение пишет на дсплее: INPUT V= 1023(к примеру)
#include <font5x7.h>
#include <LedDisplay.h>
#define dataPin 2 // connects to the display's data in
#define registerSelect 3 // the display's register select pin
#define clockPin 4 // the display's clock pin
#define enable 5 // the display's chip enable pin
#define reset 6 // the display's reset pin
#define displayLength 16 // number of characters in the display
LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin, enable, reset, displayLength);
int analogInput = 0;
int vin = 0;
void setup(){
pinMode(analogInput, INPUT);
myDisplay.begin();
myDisplay.home();
myDisplay.print("DC VOLTMETER");
delay(500);
}
void loop(){
// считывание аналогового значения
vin = analogRead(analogInput);
myDisplay.home();
myDisplay.print("INPUT V= ");
myDisplay.print(vin);
delay(500);
}
помогите найти где собака порылась?