Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **LED Control**
- - Source Code NOT compiled for: Arduino Mega
- - Source Code created on: 2024-10-30 22:02:30
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* I keep getting the error code "expected '(' before */
- /* 'val'", Does anyone know what that means and how */
- /* to fix it? */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #define red 4
- #define blue 3
- #define yellow 2
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(red, OUTPUT);
- pinMode(blue, OUTPUT);
- pinMode(yellow, OUTPUT);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- int val = digitalRead(A0);
- // Corrected syntax for the following conditions:
- if (val <= 341) {
- digitalWrite(red, HIGH);
- } else {
- digitalWrite(red, LOW); // Ensure the LED is turned off when val > 341
- }
- if (val >= 682) {
- digitalWrite(red, HIGH);
- digitalWrite(blue, HIGH);
- } else {
- digitalWrite(blue, LOW); // Ensure the LED is turned off when val < 682
- }
- if (val >= 1023) {
- digitalWrite(red, HIGH);
- digitalWrite(blue, HIGH);
- digitalWrite(yellow, HIGH);
- } else {
- digitalWrite(yellow, LOW); // Ensure the LED is turned off when val < 1023
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement