-
Fototrend
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
-
Undoroid
őstag
válasz
Undoroid #16856 üzenetére
Sziasztok!
Nos, elakadtam és ismét kérdeznék.
A példafeladatot módosítva idáig jutottam el:
/***********************************************************
File name: 09_rgbLed.ino
Description:Control the RGB LED emitting red, green, blue, yellow,
white and purple light, then the RGB LED will be off,
each state continues 1s, after repeating the above
procedure.
Website: www.adeept.com
E-mail: support@adeept.com
Author: Tom
Date: 2015/05/02
*************************************************************/
int redPin = 11; // R petal on RGB LED module connected to digital pin 11
int greenPin = 10; // G petal on RGB LED module connected to digital pin 9
int bluePin = 9; // B petal on RGB LED module connected to digital pin 10
int red2Pin = 6; // R petal on RGB LED module connected to digital pin 6
int green2Pin = 5; // G petal on RGB LED module connected to digital pin 5
int blue2Pin = 3; // B petal on RGB LED module connected to digital pin 3
void setup()
{
pinMode(redPin, OUTPUT); // sets the redPin to be an output
pinMode(greenPin, OUTPUT); // sets the greenPin to be an output
pinMode(bluePin, OUTPUT); // sets the bluePin to be an output
pinMode(red2Pin, OUTPUT); // sets the redPin to be an output
pinMode(green2Pin, OUTPUT); // sets the greenPin to be an output
pinMode(blue2Pin, OUTPUT); // sets the bluePin to be an output
}
void loop() // run over and over again
{
// Basic colors:
color(255, 0, 0); // turn the RGB LED red
delay(1000); // delay for 1 second
color(0,255, 0); // turn the RGB LED green
delay(1000); // delay for 1 second
color(0, 0, 255); // turn the RGB LED blue
delay(1000); // delay for 1 second
// Example blended colors:
color(255,255,0); // turn the RGB LED yellow
delay(1000); // delay for 1 second
color(255,255,255); // turn the RGB LED white
delay(1000); // delay for 1 second
color(128,0,255); // turn the RGB LED purple
delay(1000); // delay for 1 second
color(0,0,0); // turn the RGB LED off
delay(1000); // delay for 1 second
}
void color (unsigned char red, unsigned char green, unsigned char blue)// the color generating function
{
analogWrite(redPin, 255-red); // PWM signal output
analogWrite(greenPin, 255-green); // PWM signal output
analogWrite(bluePin, 255-blue); // PWM signal output
analogWrite(red2Pin, 255-red); // PWM signal output
analogWrite(green2Pin, 255-green); // PWM signal output
analogWrite(blue2Pin, 255-blue); // PWM signal output
}
Annyit tettem, hogy lemásoltam / megdupláztam a megfelelő parancssorokat és más neveket is adtam nekik. Ekkor a 9-10-11-es kimenet és a 3-5-6-os kimenet pontosan ugyanazokat a jeleket produkálták. Amikor ezt a sort (
void color (unsigned char red, unsigned char green, unsigned char blue)// the color generating function
{
) kezdtem el ugyanúgy lemásolni / módosítani, akkor viszont megannyi hibaüzenet fogadott feltöltés közben. Megpróbáltam kiegészíteni ilyenre is:void color (unsigned char red, unsigned char green, unsigned char blue, unsigned char red2, unsigned char green2, unsigned char blue2)// the color generating function
Erre szintén újabb hibaüzenettel gazdagodtam...A feladatom az lenne, hogy a 3-5-6-os kimeneten és a 9-10-11-es kimeneten egyidőben, de különböző jeleket (sima RGB-LED-es színkeveréseket és villogásokat) szeretnék futtatni. A nagy kérdés pedig az, hogy hogyan?
A színek létrehozása, keverése, átúsztatása (a color - delay párossal) "megy" , de nem a legszebb- és a legjobb tárhelyhasználattal, de működik!
A fő problémám az, hogy nem tudom külön-külön kezelni a két kimenetet. Nem tudok olyan parancssort létrehozni, ami ezt megoldaná.
Remélem, hogy tudtok segíteni?!
Új hozzászólás Aktív témák
- Eredeti játékok OFF topik
- Futás, futópályák
- Projektor topic
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- HiFi műszaki szemmel - sztereó hangrendszerek
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Synology NAS
- BestBuy topik
- Teljes verziós, ingyenes mobil játékok és alkalmazások
- Nothing Phone (3a) és (3a) Pro - az ügyes meg sasszemű
- További aktív témák...
- 156 - Lenovo LOQ (15IRH8) - Intel Core i5-13505H, RTX 4060
- LG 32GS94UX - 32" OLED / UHD 4K / 240Hz - 480Hz & 0.03ms / 1300 Nits / NVIDIA G-Sync / AMD FreeSync
- Surface Laptop 5 Touch 13.5 Retina i7-1265U 10mag 4.8Ghz 16GB 512GB Intel Iris XE Win11 Pro Garancia
- HIBÁTLAN iPhone 13 Pro 256GB Sierra Blue 1ÉV GARANCIA -Kártyafüggetlen, MS3744
- LG OLED & OLED evo Televíziók -30%
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest