Forum
Slut med nuværende kryptering
7
nvidia driver og Diablo 4, fix ?
3
Grafikkort PANIK !
27
Brugt Gaming PC forventningsafstemmelse
11
Har I set elpriserne for i morgen?
112
hjælp til fionde den bedste bærbar til 3000 kr
7
Kan jeg bruge DE (ISO) tastatur uden problemer?
8
Asus Kithara problem
0
Hue outdoor sensor & google home
2
Spørgsmål: Ny hardware på vej ?
9
Black Friday 2026 - Den store tilbudstråd
128
Ps5 Headset forslag?
12
Forkerte vare fra Proshop
10
Køb af ny computer
67
Hjælp til valg af CPU
32
Fejlfinding og evt. opgradering af søns computer
1
Opgradering af CPU og bundkort, max 1.500 kr
22
Edifier R1700BT erfaringer?
8
nogle her der har lg h7 suite=( højtalere sub osv?
7
Prof. VFX Artist - Beholde 3090 eller 5080?
10
Coax internet
25
køb og salg.
11
Nintendo Switch MicroSD??
5
GTA 6 reviews Perfect score
64
Hjælp til Grå skærm!
23
Dune 2000 "Remaster"
25
Hvilken NAS boks
3
Verificering på mobil
12
Switch 2 ekstra dock
8
Ny computer - websider driller i Chrome og Edge
24
Køb & Salg
S: Defekt Asus TUF Gaming bærbar
0
K: Gaming PC budget 8000-10.000
0
S: 7800X3D
2
S: 7700k + mITX + NVME
2
S: FUMA cpu køer + arctic blæser
2
V: Elgiganten Build 463 R7X3D/32/2TB/RX 9070 XT
0
K: semi defekte/slidte iphones søges
6
S: Logitech Trophy rig + HF8
6
K: 2x16gb ddr4 3200mhz. eller højere
1
V: 3070ti
5
S: Razer Naga V2 Pro
5
B: Sort 9070 XT til hvidt 9070 XT
7
S: Mayflash F101 Mini fightstick
1
S: Corsair K100 Air Trådløst Gaming Tastatur
1
K: RPi 4 model B 4 GB
1
S: HP EliteDesk 8 G1i AI PC Mini PC
2
V: RTX 4070 TI SUPER - PNY VERTO
11
K: Stationær til server
6
S: Corsair RM1000x
3
K: Razer Naga eller lign
0
S: Elgiganten Gavekort
6
S: kingston 480 gb 2,5 ssd
3
V: Asus Prime OC 5070 Ti
4
MacBook Pro Retina 13” Early 2015 - 16GB RAM
0
K: Lian Li uni fan sl-inf 7 pin kabel
7
K: købes tado smart termostater
3
S: Steelseries Nova Pro Wireless Hvid
0
S: Forskellig typer bærbar ram
1
S: Apple mus
1
B: PS5 PRO (Non disc) + Dualsense Edge
17
Forum
Slut med nuværende kryptering
7
nvidia driver og Diablo 4, fix ?
3
Grafikkort PANIK !
27
Brugt Gaming PC forventningsafstemmelse
11
Har I set elpriserne for i morgen?
112
hjælp til fionde den bedste bærbar til 3000 kr
7
Kan jeg bruge DE (ISO) tastatur uden problemer?
8
Asus Kithara problem
0
Hue outdoor sensor & google home
2
Spørgsmål: Ny hardware på vej ?
9
Black Friday 2026 - Den store tilbudstråd
128
Ps5 Headset forslag?
12
Forkerte vare fra Proshop
10
Køb af ny computer
67
Hjælp til valg af CPU
32
Fejlfinding og evt. opgradering af søns computer
1
Opgradering af CPU og bundkort, max 1.500 kr
22
Edifier R1700BT erfaringer?
8
nogle her der har lg h7 suite=( højtalere sub osv?
7
Prof. VFX Artist - Beholde 3090 eller 5080?
10
Coax internet
25
køb og salg.
11
Nintendo Switch MicroSD??
5
GTA 6 reviews Perfect score
64
Hjælp til Grå skærm!
23
Dune 2000 "Remaster"
25
Hvilken NAS boks
3
Verificering på mobil
12
Switch 2 ekstra dock
8
Ny computer - websider driller i Chrome og Edge
24
Køb & Salg
S: Defekt Asus TUF Gaming bærbar
0
K: Gaming PC budget 8000-10.000
0
S: 7800X3D
2
S: 7700k + mITX + NVME
2
S: FUMA cpu køer + arctic blæser
2
V: Elgiganten Build 463 R7X3D/32/2TB/RX 9070 XT
0
K: semi defekte/slidte iphones søges
6
S: Logitech Trophy rig + HF8
6
K: 2x16gb ddr4 3200mhz. eller højere
1
V: 3070ti
5
S: Razer Naga V2 Pro
5
B: Sort 9070 XT til hvidt 9070 XT
7
S: Mayflash F101 Mini fightstick
1
S: Corsair K100 Air Trådløst Gaming Tastatur
1
K: RPi 4 model B 4 GB
1
S: HP EliteDesk 8 G1i AI PC Mini PC
2
V: RTX 4070 TI SUPER - PNY VERTO
11
K: Stationær til server
6
S: Corsair RM1000x
3
K: Razer Naga eller lign
0
S: Elgiganten Gavekort
6
S: kingston 480 gb 2,5 ssd
3
V: Asus Prime OC 5070 Ti
4
MacBook Pro Retina 13” Early 2015 - 16GB RAM
0
K: Lian Li uni fan sl-inf 7 pin kabel
7
K: købes tado smart termostater
3
S: Steelseries Nova Pro Wireless Hvid
0
S: Forskellig typer bærbar ram
1
S: Apple mus
1
B: PS5 PRO (Non disc) + Dualsense Edge
17
- Denne tråd er over 6 måneder gammel
Er du sikker på, at du har noget relevant at tilføje?
Arduino question
Af Girl in distress gæst
Hi
Can anybody help me figuring out which three different code blocks an Arduino sketch usually consist of? I'm kind of new to this...
Can anybody help me figuring out which three different code blocks an Arduino sketch usually consist of? I'm kind of new to this...
Please elaborate.
Is this a question from an assignment you've been given by a teacher, based on something you were supposed to read?
If so, I'm guessing that you were supposed to read this:
http://www.arduino.cc/en/Tutorial/S...
In which case the answer is Comments, Variables and Functions.
Depending on the context of the question, it could also be Variables, Setup() and Loop().
Is this a question from an assignment you've been given by a teacher, based on something you were supposed to read?
If so, I'm guessing that you were supposed to read this:
http://www.arduino.cc/en/Tutorial/S...
In which case the answer is Comments, Variables and Functions.
Depending on the context of the question, it could also be Variables, Setup() and Loop().
Girl in distress
#2
Gæst
11-06-2011 16:04
Okay.. it is an assigment, and the last thing you wrote (variables, setup, and loop) was also what my friends and I concluded. But because we did not fully understand what a code block was, we were not entirely sure of the answer. But thanks for the answer! :)
You can also create a custom function you can "launch" from your main loop. You declare these functions with the "void" command, just like the main loop and setup functions
Ex. if you want to set the states for an LED using only one command instead of writing the same piece of code everytime, you can create a seperate function to handle the LED state:
void rgbLED(String color) // set color of RGB LED, r=red g=green b=blue
{
if (color == "r"){
digitalWrite(RGB_Rled, HIGH);
digitalWrite(RGB_Gled, LOW);
digitalWrite(RGB_Bled, LOW);
}
else if (color == "g"){
digitalWrite(RGB_Rled, LOW);
digitalWrite(RGB_Gled, HIGH);
digitalWrite(RGB_Bled, LOW);
}
else if (color == "b"){
digitalWrite(RGB_Rled, LOW);
digitalWrite(RGB_Gled, LOW);
digitalWrite(RGB_Bled, HIGH);
}
}
if you then call the rgbLED("X"); from ex. your loop(), the program would go to the void rgbLED, set the LED according to what you wanted, and return to the main loop again.
It is also possible to create functions, that returns an int when you call the function (ex if you only need to scan an analog input at certain points in your code)
void loop()
{
digitalWrite(Ri2c_led, LOW);
rgbLED("g");
cupLED("g");
lcd.init(); // initialize the lcd lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("DrinkMaster9000");
lcd.setCursor(0, 1);
lcd.print(" = Insert Cup = ");
delay(1000);
int irtr = chkIR(); // check if cup is inserted, return to loop (with LOW) if IR is blocked
}
int chkIR() {
int val = readMux(5); //IR transistor is connected to MUX channel 5
if(val>IRLOW && val
Ex. if you want to set the states for an LED using only one command instead of writing the same piece of code everytime, you can create a seperate function to handle the LED state:
void rgbLED(String color) // set color of RGB LED, r=red g=green b=blue
{
if (color == "r"){
digitalWrite(RGB_Rled, HIGH);
digitalWrite(RGB_Gled, LOW);
digitalWrite(RGB_Bled, LOW);
}
else if (color == "g"){
digitalWrite(RGB_Rled, LOW);
digitalWrite(RGB_Gled, HIGH);
digitalWrite(RGB_Bled, LOW);
}
else if (color == "b"){
digitalWrite(RGB_Rled, LOW);
digitalWrite(RGB_Gled, LOW);
digitalWrite(RGB_Bled, HIGH);
}
}
if you then call the rgbLED("X"); from ex. your loop(), the program would go to the void rgbLED, set the LED according to what you wanted, and return to the main loop again.
It is also possible to create functions, that returns an int when you call the function (ex if you only need to scan an analog input at certain points in your code)
void loop()
{
digitalWrite(Ri2c_led, LOW);
rgbLED("g");
cupLED("g");
lcd.init(); // initialize the lcd lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("DrinkMaster9000");
lcd.setCursor(0, 1);
lcd.print(" = Insert Cup = ");
delay(1000);
int irtr = chkIR(); // check if cup is inserted, return to loop (with LOW) if IR is blocked
}
int chkIR() {
int val = readMux(5); //IR transistor is connected to MUX channel 5
if(val>IRLOW && val