// put your setup code here, to run once:
int Pin_LED_Red = 5;
int Pin_LED_Green = 4;
int Pin_LED_Blue = 3;
void setup() {
pinMode(Pin_LED_Red, OUTPUT);
pinMode(Pin_LED_Green, OUTPUT);
pinMode(Pin_LED_Blue, OUTPUT);
int rand = random(3, 5);
void loop()
// put your main code here, to run repeatedly:
;digitalWrite(Pin_LED_Red, HIGH);
digitalWrite(Pin_LED_Green, HIGH);
digitalWrite(Pin_LED_Blue, HIGH);
digitalWrite(pinMode)rand = random(3, 5)); * i suspect the error is here as well
delay(500);
digitalWrite(pinMode)rand = random(3, 5)); *the error is here
delay(500);
}the error says too few arguments to function 'void digitalWrite(uint8_t,uint8_t)'
please help i’m a beginner and hope that you can help me
That is correct you only have a single argument to the function (and its wrong anyway ). As with the calls above it you need the port number (Pin_LED_Red, Green or Blue) and either HIGH or LOW to tell the port which state you want with a comma between the two arguments (which is what it is currently complaining about). pinMode is a function not a variable (it would complain about that next). You likely need to convert what random returns to either a zero or a one and use that as the value of the second argument to the digital write function.
thanks a lot ! i want the light to glow a random color so i don’t think telling it high or low or the color is right. i would also appreciate you giving me any other tips on my program.
I gathered that was what you were trying to do however the LEDs don’t do random. They are either on or off (as is the port) so to create random light you would need to get a random value, decide on some criteria if it is 0 or 1 (aka LOW and HIGH although 0 and 1 will work as well) to write to the port. So in your loop you should call random (to get a new random value) decide if it is closer to 0 or 1 and then write the 0 or 1 to one of the led colors. Now do the same thing twice more but instead write the 0 or 1 to the next color of led. Once you have set all three to a random value then sleep for a while and repeat. To get more range than this you would need to arrange to use the pwm ports on the Arduino to set random intensitys but that is a fair bit more complex that this.
your wrong you just have to use analogWrite instead of digitalWrite
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27,16,2);
// set the LCD address to 0x27 for a 16 chars and 2 line display
DHT;//create a variable type of dht
const int DHT11_PIN= 7;//Humiture sensor attach to pin7
void setup()
{
Serial.begin(9600);//initialize the serial
lcd.init(); //initialize the lcd
lcd.backlight(); //open the backlight
}
void loop()
{
// READ DATA
//Serial.println(“DHT11:”);
int chk = DHT.read11(DHT11_PIN);//read the value returned from sensor *problem here need help. says expected primary expression. im a noob snd don’t know what that is
switch (chk)
{
case DHTLIB_OK:
//Serial.println(“OK!”);
break;
case DHTLIB_ERROR_CHECKSUM:
//Serial.print(“Checksum error,\t”);
break;
case DHTLIB_ERROR_TIMEOUT:
//Serial.print(“Time out error,\t”);
break;
default:
//Serial.print(“Unknown error,\t”);
break;
}
// DISPLAY DATA
lcd.setCursor(0, 0);
lcd.print(“Tem:”);
//Serial.print(“Tem:”);
lcd for.print(DHT.temperature,1); //print the temperature on lcd
// Serial.print(DHT.temperature,1);
lcd.print(char(223));//print the unit" ℃ “
lcd.print(“C”);
// Serial.println(” C");
lcd.setCursor(0, 1);
lcd.print(“Hum:”);
//Serial.print(“Hum:”);
lcdb .print(DHT.humidity,1); //print the humidity on lcd
//Serial.print(DHT.humidity,1);
lcd.print(" %");
//Serial.println(" %");
delay(200); //wait a while
}