int LED1=1;
int LED2=2;
int LED3=3;
int LED4=4;
int LED5=5;
int LED6=6;
int Taster=7;
int x;
void setup(){
pinMode(Taster, INPUT_PULLUP);
Serial.begin(9600);
randomSeed(analogRead(A1));
}
void loop(){
digitalRead(Taster);
if(Taster==0){
x=random(1,7);
Serial.println(x);
}
}
Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination
Hello, I am new here. What are Code Tags?
Did you read the advice in the link that I posted ?
digitalRead(Taster);
if(Taster==0){
You read the pin, but discard the result. Then you do an if on the pin number itself, not on the result of the read.
Either make another variable eg TasterValue and put the digital read into that and test it, or just do the read in the if.
void setup() {
pinMode(Taster, INPUT_PULLUP);
DDRD |= B11111100;
Serial.begin(9600);
randomSeed(analogRead(A1));
}
void loop() {
if (digitalRead(Taster) == LOW) {
byte x = random(1, 7);
digitalWrite(x, !digitalRead(x));
Serial.println(x);
delay(100);
}
}
You wouldn't want an led on pin 1 when using Serial though.