Hirdetés
- Milyen videókártyát?
- Milyen asztali (teljes vagy fél-) gépet vegyek?
- Vezetékes FEJhallgatók
- OLED TV topic
- Nem akármilyen módon ugrik rá a memóriapánikra a Valve
- Otthoni időjárás-állomás
- Philips LCD és LED TV-k
- Milyen billentyűzetet vegyek?
- A Cherry többé nem gyárt kapcsolókat
- Kormányok / autós szimulátorok topikja
-
PROHARDVER!
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
2thletme2day
őstag
válasz
its_grandpa
#21981
üzenetére
A 101-es sorban lévő 23:46-ot csak azért írtam be, hogy lássam, hogy kijelzi-e rendesen az első digitet. A válaszb sajnos nem. Az első digit első szegmense működik csak.
A LEDCLOCK_COUNT nálam azért nem 216 hanem 252 mert 24 órás formátumú órát csináltam. Az eredeti pedig csak 12 órás formátumú ahol az legelső digit csak az egyest jeleníti meg.
Az offset értékét kell változtatni? Csak mert szerintem az offset ugyanaz maradhat. Annyi a különbség, hogy most az első digit nem csak 2 szegmensből áll hanem 7-ből.
Tessék. Az elmaradt github link a projekthez. [link]
-
2thletme2day
őstag
Sziasztok.
Egy kis segítségre lenne szükségem.
Nem nagyon értek az arduinohoz viszont van egy projekt amihez kell. 7 szegmenses kijelzőkkel órakijelzés. A probléma a következő.
Most 23:46-ot kéne mutatnia viszont mint látható csak az első szegmens megy valamiért. Az eredeti kód 12 órás formátumú ennek megfelelő szegmens és ledszámmal. Maga a vezetékezés jónak tűnik mert végig tudom csipogni az 5V, GND és adat vonalat az előző számjegyről is. Így szakadás nincs ezért gondolok szoftveres problémára amihez sajnos nem értek.
A kód a következő:
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#endif
#include <DS3231_Simple.h>
DS3231_Simple Clock;
// Create a variable to hold the time data
DateTime MyDateAndTime;
// Which pin on the Arduino is connected to the NeoPixels?
#define LEDCLOCK_PIN 6
#define LEDDOWNLIGHT_PIN 5
// How many NeoPixels are attached to the Arduino?
#define LEDCLOCK_COUNT 252
#define LEDDOWNLIGHT_COUNT 12
//(red * 65536) + (green * 256) + blue ->for 32-bit merged colour value so 16777215 equals white
// or 3 hex byte 00 -> ff for RGB eg 0x123456 for red=12(hex) green=34(hex), and green=56(hex)
// this hex method is the same as html colour codes just with "0x" instead of "#" in front
uint32_t clockMinuteColour = 0x800000; // pure red
uint32_t clockHourColour = 0x008000; // pure green
int clockFaceBrightness = 0;
// Declare our NeoPixel objects:
Adafruit_NeoPixel stripClock(LEDCLOCK_COUNT, LEDCLOCK_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripDownlighter(LEDDOWNLIGHT_COUNT, LEDDOWNLIGHT_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
//Smoothing of the readings from the light sensor so it is not too twitchy
const int numReadings = 30;
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
long total = 0; // the running total
long average = 0; // the averagevoid setup() {
Serial.begin(9600);
Clock.begin();
stripClock.begin(); // INITIALIZE NeoPixel stripClock object (REQUIRED)
stripClock.show(); // Turn OFF all pixels ASAP
stripClock.setBrightness(100); // Set inital BRIGHTNESS (max = 255)
stripDownlighter.begin(); // INITIALIZE NeoPixel stripClock object (REQUIRED)
stripDownlighter.show(); // Turn OFF all pixels ASAP
stripDownlighter.setBrightness(50); // Set BRIGHTNESS (max = 255)
//smoothing
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}
void loop() {
//read the time
readTheTime();
//display the time on the LEDs
displayTheTime();//Record a reading from the light sensor and add it to the array
readings[readIndex] = analogRead(A0); //get an average light level from previouse set of samples
Serial.print("Light sensor value added to array = ");
Serial.println(readings[readIndex]);
readIndex = readIndex + 1; // advance to the next position in the array:
// if we're at the end of the array move the index back around...
if (readIndex >= numReadings) {
// ...wrap around to the beginning:
readIndex = 0;
}
//now work out the sum of all the values in the array
int sumBrightness = 0;
for (int i=0; i < numReadings; i++)
{
sumBrightness += readings[i];
}
Serial.print("Sum of the brightness array = ");
Serial.println(sumBrightness);
// and calculate the average:
int lightSensorValue = sumBrightness / numReadings;
Serial.print("Average light sensor value = ");
Serial.println(lightSensorValue);
//set the brightness based on ambiant light levels
clockFaceBrightness = map(lightSensorValue,50, 1000, 200, 1);
stripClock.setBrightness(clockFaceBrightness); // Set brightness value of the LEDs
Serial.print("Mapped brightness value = ");
Serial.println(clockFaceBrightness);
stripClock.show();
//(red * 65536) + (green * 256) + blue ->for 32-bit merged colour value so 16777215 equals white
stripDownlighter.fill(16777215, 0, LEDDOWNLIGHT_COUNT);
stripDownlighter.show();
delay(5000); //this 5 second delay to slow things down during testing
}
void readTheTime(){
// Ask the clock for the data.
MyDateAndTime = Clock.read();
// And use it
Serial.println("");
Serial.print("Time is: "); Serial.print(MyDateAndTime.Hour);
Serial.print(":"); Serial.print(MyDateAndTime.Minute);
Serial.print(":"); Serial.println(MyDateAndTime.Second);
Serial.print("Date is: 20"); Serial.print(MyDateAndTime.Year);
Serial.print(":"); Serial.print(MyDateAndTime.Month);
Serial.print(":"); Serial.println(MyDateAndTime.Day);
}
void displayTheTime(){
stripClock.clear(); //clear the clock face
int firstMinuteDigit = MyDateAndTime.Minute % 10; //work out the value of the first digit and then display it
displayNumber(firstMinuteDigit, 0, clockMinuteColour);
int secondMinuteDigit = floor(MyDateAndTime.Minute / 10); //work out the value for the second digit and then display it
displayNumber(secondMinuteDigit, 63, clockMinuteColour);
int firstHourDigit = MyDateAndTime.Hour; //work out the value for the third digit and then display it
firstHourDigit = firstHourDigit % 10;
displayNumber(firstHourDigit, 126, clockHourColour);
int secondHourDigit = MyDateAndTime.Hour; //work out the value for the fourth digit and then display it
secondHourDigit = secondHourDigit / 10;
displayNumber(secondHourDigit, 189, clockHourColour);
}
void displayNumber(int digitToDisplay, int offsetBy, uint32_t colourToUse){
switch (digitToDisplay){
case 0:
digitZero(offsetBy,colourToUse);
break;
case 1:
digitOne(offsetBy,colourToUse);
break;
case 2:
digitTwo(offsetBy,colourToUse);
break;
case 3:
digitThree(offsetBy,colourToUse);
break;
case 4:
digitFour(offsetBy,colourToUse);
break;
case 5:
digitFive(offsetBy,colourToUse);
break;
case 6:
digitSix(offsetBy,colourToUse);
break;
case 7:
digitSeven(offsetBy,colourToUse);
break;
case 8:
digitEight(offsetBy,colourToUse);
break;
case 9:
digitNine(offsetBy,colourToUse);
break;
default:
break;
}
}
Új hozzászólás Aktív témák
- Samsung Galaxy Tab S7+ 5G
- BESZÁMÍTÁS! MSI Z370 i7 8700K 16GB DDR4 500GB SSD RTX 3060 12GB Rampage SHIVA ADATA 600W
- BESZÁMÍTÁS! MSI B450M R7 5700X 32GB DDR4 500GB SSD RTX 4060 Ti 8GB Zalman Z1 PLUS Cooler Master 700W
- BESZÁMÍTÁS! Gigabyte B550M R7 3700X 32GB DDR4 512GB SSD RTX 3060Ti 8GB Zalman Z1 PLUS CM 700W
- BESZÁMÍTÁS! Gigabyte H610M i3 12100F 16GB DDR4 512GB SSD RX 5700 8GB Zalman Z1 PLUS ADATA 600W
- Újszerű Apple Macbook Air 13 - M2 - 8/256GB (MLY33MG/A) éjfekete - 141 Ciklus - 1+ év garancia - HUN
- HIBÁTLAN iPhone 13 mini 128GB Pink -1 ÉV GARANCIA - Kártyafüggetlen, MS3050, 100% Akkumulátor
- AKCIÓ! HP EliteBook x360 830 G7 i5-10210U 16GB 512GB 1 év garancia
- Azonnali készpénzes Sony Playstation 5 lemezes és digitális felvásárlás személyesen/csomagküldéssel
- ÁRGARANCIA!Épített KomPhone i5 12400F 16/32/64GB RAM RTX 3060 12GB GAMER PC termékbeszámítással
Állásajánlatok
Cég: BroadBit Hungary Kft.
Város: Budakeszi
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
ekkold

