Noob need some basic help - L298N + ws2812B

Hello,

i am coding a Little bit with Arduino, switching on lins and switching them off and other very basic things.

I coded a small Programm that switches on Pins to controll a L298N H brdige, basically nothing else than a relay… Very simple and very straight forward.

Now i Need a Evolution of My Programm and have no idea how to solve this, even not how to start the coding, perhaps anybody could help, would be worth a Cup of coffee via PayPal:

I push a button then following should happen:
a short Beep, then i want to switch one pin on and one pin off on the GPIO for 100 seconds, after that i want Change the state of the two Pins for another 100 seconds. The one which was on has now to be off and vice versa. No Inputs via the push button should be allowed during this loop. At the end again a Beep. When the System starts and when the loop Ends a WS2812b led ring with 12 LED’s should be filled solid. during the 2 x 100 seconds it should be filled with a moving colorful pattern like the standtest of the Adafruit lib under Arduino.

Basically the Programm should be Pretty easy but i am not able to Code it as i am not able to understand the workflow and the nodes.

Please anybody could help me out?

Kind regards
Tom

During the

Hard to even start the program for you since you don’t say what the state of the pins are (or can be) before or after you push the button.

Are the two pins always in opposite state? If so, you don’t need a bunch of programming for the second pin. Just connect a “not” node to whatever controls the first pin and use that to control the second pin.

The simplest XOD programs just change output state whenever input state changes; there is no “program flow” controlling a sequence of actions. In your new program, you want a series of actions to occur after a single input. To do that, you will need to use pulses to create that kind of program flow. Since you want something to happen for a specific amount of time, you probably want to use “delay” nodes to help manage the pulses. The traffic light example is a good introduction to how this works.

You have two 100 second delays, so you will probably want two “delay” nodes. You want the light ring to do the same thing during both delays, so you can use an “or” node to join the two delay-ACT pins and use that to control what the light ring is doing. The delay-ACT pins will also be used to control the GPIO pins.

OK, so let me the explain the Project more detailed. The L298 H Bridge can be controlled by 2 Pins from the Arduino by simply putting the pins High or Low. I have a device which i Need to controll by an Arduino. The device has one push button. By pushing the button the 2 Pins shall be one high and one low. After 100 seconds the Status has to Change to one low and the other high. In this way i am controlling + and - of the Output of the L298 H. Additionally i messed around with an WS2811B LED ring. With a library i can get this ring to work but not together with the button and the 2 digital output Pins… programming in Adruino the chenged states, the Beeps and so on is really easy and strqight Forward but implementing a second Task that has to run parallel during the delay is a Problem i am not able to solve so far. During the delay Nothing happens and i am not able to perfom another function?

What is the code you have so far?

Hi, the Code i have working with a single LED is as followed:

// Digispark Code

const byte TASTER = 0; // push button on Pin 0
const byte LED = 1; // LED am DIGISPARK auf Pin 1 - here could be the WS2812B be connected
const byte In1 = 2; // In1 am L298N
const byte In2 = 3; // In2 am L298N
const byte beeper = 4; // Beeper Pin 4

void setup()
{
pinMode(TASTER, INPUT_PULLUP); // Pin 0 with int pullup
digitalWrite (LED,LOW); // Internal LED off - here has to come a solid fill of the WS2812B LED Ring
digitalWrite (In1,LOW); // L298N ausschalten
digitalWrite (In2,LOW); // L298N ausschalten
}

void loop()
{
if (digitalRead(TASTER)== LOW) // due to internal pullup pressed button is now LOW
{
digitalWrite (LED,HIGH); // switch on internal LED - here has to come the animated WS2812B in place
digitalWrite (In1,HIGH); // L298N in the first direction
digitalWrite (In2,LOW); // L298N in the first direction
delay(100000); // 100 seconds in direction 1
tone(4, 2400, 1000); // one second beep
digitalWrite (In1,LOW); // L298N in the second direction
digitalWrite (In2,HIGH); // L298N in the second direction
delay(100000); // 100 seconds in direction 1
tone(beeper, 2400, 1000); // one second beep
}

if (digitalRead(TASTER)== HIGH) // due to internal pullup released button is now HIGH
{
digitalWrite (LED,LOW); // switch off the internal LED
digitalWrite (In1,LOW); // L298N switch off
digitalWrite (In2,LOW); // L298N switch off
delay(80); // Taster Entprellen 80 ms
}
}

i am trying to realise this with XOD because i am to unexperienced to implement the WS2812B LED Ring in this Code to be honest.

Sorry for the bad english… Native Austrian here :slight_smile: