- iPhone topik
- Azonnali mobilos kérdések órája
- Poco F7 – bajnokesélyes
- A napon sütkérezik a OnePlus 15
- Megérkezett végre a várva-várt órafrissítés
- „Új mérce az Android világában” – Kezünkben a Vivo X300 és X300 Pro
- Samsung Galaxy S24 - nos, Exynos
- Fotók, videók mobillal
- Apple Watch
- Okosóra és okoskiegészítő topik
-
Mobilarena
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
- Bomba Ár! Lenovo IdeaPad Flex 5 Ryzen 3 5300U I 4GB I 128SSD I 14" FHD Touch I W11 I Cam I Garancia!
- Bomba ár! HP ProBook X360 435 G7 - Ryzen 3/5 I 8GB I 256SSD I 13,3" FHD Touch I W11 I Cam I Gari!
- Bomba ár! Lenovo ThinkPad X13 G1 - AMD Ryzen 5 PRO I 8GB I 256SSD I 13,3" FHD I Cam I W11 I Gari!
- Bomba Ár! Lenovo ThinkPad E14 G2 AMD - Ryzen 5 I 8GB I 256SSD I 14" FHD I HDMI I W11 I Gari
- Bomba ár! Lenovo ThinkPad T14s G1 - i7-10G I 16GB I 512GB SSD I 14" FHD Touch I Cam I W11 I Gari!
- iMac Pro 1.1 2017 Intel Xeon W2150B 64GB 1TB VEGA 64 16GB!!! 1 év garancia!
- HIBÁTLAN iPhone 13 mini 128GB Starlight -1 ÉV GARANCIA - Kártyafüggetlen, MS3276
- Dell UltraSharp 27" QHD 2.5K 100% AdobeRGB 1 év garancia
- HIBÁTLAN iPhone 13 mini 128GB Midnight -1 ÉV GARANCIA - Kártyafüggetlen, MS3330
- ÁRGARANCIA!Épített KomPhone Ryzen 5 7600X 32/64GB RAM RTX 5070 12GB GAMER PC termékbeszámítással
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest