Moderator: tilz0R
pomar je napisal/-a:Ali je še možno naredit malo šolo na temo kako priklopit display na arduino?
static const int PIN_POT = A0;
static const int PIN_CLOCK = 8;
static const int PIN_DATA = 4;
static const int PIN_LATCH = 7;
static const char LEDSEG_CNT = 10;
static const char LEDSEG[LEDSEG_CNT] = {
B01110111,
B01000001,
B00111011,
B01101011,
B01001101,
B01101110,
B01111110,
B01000011,
B01111111,
B01001111 };
void setup()
{
Serial.begin(115200);
pinMode(PIN_POT, INPUT);
pinMode(PIN_CLOCK, OUTPUT);
pinMode(PIN_DATA, OUTPUT);
pinMode(PIN_LATCH, OUTPUT);
}
void loop()
{
int an = analogRead(PIN_POT);
//Serial.print(an);
//Serial.print("\n");
digitalWrite(PIN_LATCH, LOW);
int number = an;
for(int c=0; c<4; c++)
{
shiftOut(PIN_DATA, PIN_CLOCK, LSBFIRST, LEDSEG[number % 10]);
number = number / 10;
}
digitalWrite(PIN_LATCH, HIGH);
delay(10);
}
#include <LiquidCrystal.h>
static const int PIN_POT = A0;
static const int PIN_LCD_BACKLIGHT = 13;
static const int PIN_LCD_DB7 = 12;
static const int PIN_LCD_DB6 = 11;
static const int PIN_LCD_DB5 = 10;
static const int PIN_LCD_DB4 = 9;
static const int PIN_LCD_E = 8;
static const int PIN_LCD_RS = 7;
LiquidCrystal _LCD(PIN_LCD_RS, PIN_LCD_E, PIN_LCD_DB4, PIN_LCD_DB5, PIN_LCD_DB6, PIN_LCD_DB7);
void setup()
{
Serial.begin(115200);
_LCD.begin(16, 2);
pinMode(PIN_POT, INPUT);
pinMode(PIN_LCD_BACKLIGHT, OUTPUT);
digitalWrite(PIN_LCD_BACKLIGHT, HIGH);
}
void loop()
{
int an = analogRead(PIN_POT);
Serial.print(an);
Serial.print("\n");
_LCD.setCursor(0,0);
_LCD.print("Value:");
_LCD.setCursor(0,1);
_LCD.print(an);
_LCD.print(" ");
}
Po forumu brska: 0 registriranih uporabnikov in 1 gost