Quantcast
Channel: Tweaking4All.com » All Posts
Viewing all articles
Browse latest Browse all 142

Reply To: LED-matrix with WS2812b LED-stripes project

$
0
0

Even though this is an English forum; if you really get stuck with the English language, throwing in a few German expressions is OK.
I do speak German as well but would like to keep the forum posts as readable as possible for other users. 

I’m not 100% clear of the issue you’re running into, but I did notice something in your loop() that will cause issues;

void loop() {
  //1. aufblinken 
  if (aufblinkeninput == HIGH) {
    TwinkleRandom(); //if the pin aufblinkeninput is HIGH the function TwinkleRandom starts
  } ...
}

I see you want to test if a button state is HIGH or not.
You properly define the button on that pin as such in setup().

However, … you never read the actual button state. In your code you read the value of the variable (holding the pin number) instead.

So in setup() you set a particular Arduino pin to be an input for a button:

pinMode(aufblinkeninput, INPUT);

But in the loop you’re testing this fixed number (aufblinkeninput) to be HIGH or not.
However, this would be the pin number for that button (int aufblinkeninput = 12; ), and not the actual value of what is going on on that pin.
The state of the button is not being read either. You’ll need to use the “digitalRead()” function for that.

A short recap for that particular example (you’ll need to apply this to the other variables as well)

This is what you had:

int aufblinkeninput = 12;
...
void setup() {
  ...
  
  pinMode(aufblinkeninput, INPUT);
  ...
}
void loop() {
  ...
  
 if( aufblinkeninput == HIGH) {                                                           
   TwinkleRandom();
 }
 
 ...
}

Now change that to this (eg. you will need to apply this to the other buttons as well;

#define aufblinkeninput 12  // define the pin for this button
...
void setup() {
  ...
  
  pinMode(aufblinkeninput, INPUT); 
  ...
}
void loop() {
  ...
  
  if (digitalRead (aufblinkeninput) == HIGH) {
    TwinkleRandom(); 
  }
  ...
}

(I made the changes bold)

Hope this helps you get further with your project 


Viewing all articles
Browse latest Browse all 142

Trending Articles