Does any of you experts want to help a noob so that I can get my scetch ready?

Dear Arduino Community,

I have already read through a lot of tuturials and topics but unfortunately I have not come to my conclusion. Maybe there are some nice people who can help a total beginne

I wrote a code( hardcoded) that works. Unfortunately, I am unable to implement another sequence in my existing cod

With the examples in the Arduino IDE, I don't get to my goal, which should actually be very simple but without help not for me. I absolutely need a kick-off and the right code to finally get my project up and running. Sending the code to an my Arduino Nano is not a problem for me but I just get to a final solution of it after days of trying it out. I need ad add another sequence to my code. with a few bytes to my TX Pin.

i am using Arduino Nano

Here is my Code :

void setup() {
// initialize serial:
digitalWrite(LED_BUILTIN, 0.3);
Serial.begin(9600);
Serial.write(0xA6);
Serial.write(0x12);
Serial.write(0x02);
Serial.write(0x10);
Serial.write(0x14);
Serial.write(0xCF);
delay(500);
digitalWrite(LED_BUILTIN, 0.7);
Serial.write(0xA6);
Serial.write(0x12);
Serial.write(0x02);
Serial.write(0x11);
Serial.write(0x14);
Serial.write(0x0B);
digitalWrite(LED_BUILTIN, 0);

}

void loop() {
digitalWrite(LED_BUILTIN, 1);
delay(500);
Serial.write(0xA6);
Serial.write(0x12);
Serial.write(0x02);
Serial.write(0x15);
Serial.write(0x14);
Serial.write(0x30);
digitalWrite(LED_BUILTIN, 0);
}

Again i use an Arduino Nano !!!
And i will implement
this code in this my Scetch above : to send TX Pin =

0x3A, 0x13, 0x01, 0x16, 0x79 every 5 sec need a loop unlimited.

Please don't look at the code this i will make much nicer and beautiful when i am finally got to the finish with my code thats will work with .

your help or the way to how I get there it can't be not so difficult for you experts but for me it can be and my head is smoking away. Many thanks to everyone who helps me to finalize the code. Maybe you will give me a few tips on how I can make the code even more beautiful. Many thanks in advance for the help of a noob :slight_smile:

My impression: Nobody understands what you want to achieve. If the code shown isn't relevant, why is it there?
Suggestion: Describe the goal of your program and leave out the unnecessary.

d3tonator:
And i will implement
this code in this my Scetch above : to send TX Pin =

0x3A, 0x13, 0x01, 0x16, 0x79 every 5 sec need a loop unlimited.

Welcome to the forum. Please post your code according forum guidelines. See here:

Read this before posting a programming question ...

I don't understand if you just need to send the new pattern 5 seconds or send one pattern every 0.5 seconds and the other every 5 seconds. If you need to send both then you should not use delay() but millis(). Here are some tutorials that will help you:

BlinkWithoutDelay

Arduino Multiple Things

Several Things at a Time

You want to send "Symbol Von der Community überprüft" to the serial console ?

Why not Serial.println( "Symbol Von der Community überprüft" ) ?

If you want to add new lines, embed '\n' sequences in the text.

To send it every 5 seconds. use millis() to determine when 5 seconds have elapsed, then perform the writes and watch for when 5 more seconds have gone by. See “blink without delay” for examples.

You could but the data into arrays, and then run a simple for() loop to send them out.

for (x = 0; x < 6; x=x+1){
Serial.write ( array1[x] );
}

where you define:
byte array1[] = {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF,};
byte array2[] = {next set of data};
byte array3[] = {another set of data};
byte array4[] = {0x3A, 0x13, 0x01, 0x16, 0x79,};
etc.

First many thanks for all your fast answers .

@ RudolfAtRTC i will only

send this signal as an array every 5 seconds to the TX Pin .

0x3A, 0x13, 0x01, 0x16, 0x79 every 5 sec to the TX pin in a loop for every 5 sec unlimited to prevent to stop the sequence while this is importand to let the programm run to not turn off my batterie for my e bike. this is a simple Signal to send to my e bike battery as Hearbeat function. I hope i this was understandable. and sorry for my English i am learning to i am German. :slight_smile:

CrossRoads:
To send it every 5 seconds. use millis() to determine when 5 seconds have elapsed, then perform the writes and watch for when 5 more seconds have gone by. See “blink without delay” for examples.

You could but the data into arrays, and then run a simple for() loop to send them out.

for (x = 0; x < 6; x=x+1){

Serial.write ( array1 );
}

where you define:
byte array1 = {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF,};
byte array2 = {next set of data};
byte array3 = {another set of data};
byte array4 = {0x3A, 0x13, 0x01, 0x16, 0x79,};
etc.

and last but not least many thanks @CrossRoads for your simplified code and tip how i can get it much more simple to make the hole code to work i hope. I will read all the the improved links what @ToddL1962 send to me many thanks .

And @ 6v6gt no i dont need send it to the srial console while i dont need to see the output. i hope i explained that correctly.

i will read all posted informations and then i will write the new code to let it check from you nice helpfull guys. Thank you very much for your support. best regards Toni aka D3TONATOR

Hello Community I am back with more understanding.
First of all I would like to thank everyone who helped me and made me think. And after reading Matt Gemmell’s article Try things! E-BOOK Try Things from Matt Gemmell my ambition got better of me and I started trying things out myself before asking questions. This resulted in a completely new code. And since no one knew what the code is for and I still got help I would like to explain it briefly and then reduce myself only to my questions about the code.

This is about a code to bring my e-scooter to run ( MY TIER). Some Bytes i got from a Forum about E-Scooter but i doesn’t Copy Paste this Code i wrote it all Allone after 1 WEEK learning about Arduino C++ . I have never ever before got my brain on Coding like i am told you all i am absolute beginner.

Now to my first new attempt. After I have learned many new things last week I wanted to ask you now what I can improve where are still errors in my new code? And will it Work ? and last but no least will my e-scooter and apartment burn down if I connect the Nano ?

#include <Arduino.h>

int powerPin = 27;//INITIALIZE POWER PIN ON PIN 27 = 5 VOLT (Arduino Nano)
int serialPin_RX = 0;// INITIALIZE SERIAL PIN RX = 0 (Arduino Nano)

byte messageA[] = {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF}; //SOME SORT OF UNKNOWN COMMAND THAT IS SENT EVERYTIME SCOOTER TURNS ON
byte messageB[] = {0xA6, 0x12, 0x02, 0x11, 0x14, 0x0B}; // TURNS ON ESC AND DISPLAY IN MPH
byte messageC[] = {0xA6, 0x12, 0x02, 0x05, 0x14, 0xDC}; // LOOP CODE TO STAY ON: TURNS ON HEADLIGHT, ESC ON, AND DISPLAY IN MPH
byte messageD[] = {0xA6, 0x12, 0x02, 0x85, 0x24, 0x4D}; // LOOP TO MODIFY AND TEST
byte messageE[] = {0x3A, 0x13, 0x01, 0x16, 0x79}; // EVERY 5 SEC THE CONTROLLER SENDS A "REQUEST STATUS/UNLOCK" SIGNAL TO THE BATTERY ON THE BLUE (Tx) WIRE WITH 9600 BAUD SERIAL: 0x3A, 0x13, 0x01, 0x16, 0x79

void setup() {
// INITIALIZE SERIAL WITH BAUDRATE (9600)
Serial.begin(9600);


pinMode(powerPin, OUTPUT);//POWER PIN BLUE (TX) WIRE AT PIN 27= 5V Arduino Nano
digitalWrite(powerPin, HIGH);//DIGITAL WRITE / POWER PIN ON, SEND MESSAGES C,D,E WITH 9600 BAUDRATE TO BLUE (TX) WIRE AT PIN 27= 5V ARDUINO NANO

pinMode(serialPin_RX, INPUT);//SERIAL PIN (RX) INPUT
digitalWrite(serialPin_RX, HIGH);//SERIAL PIN (RX)ON, SEND MESSAGE,D,E AS INPUT. AT MESSAGE E THE BATTERY REPLIES WITH AN EXTENSIVE STATUS REPORT ON THE GREEN (Rx) WIRE 

Serial.write(messageA, sizeof(messageA));//SOME SORT OF UNKNOWN COMMAND THAT IS SENT EVERYTIME WHEN SCOOTER TURNS ON
//delay(500);// WAIT 0,5 SEC (NOT ON)
//Serial.write(messageB, sizeof(messageB));// TURNS ON ESC AND DISPLAY IN MPH (NOT ON)

}

void loop() {
delay(500);// WAIT 0,5 SEC
Serial.write(messageD, sizeof(messageD));// SERIAL WRITE MESSAGE D

delay(5000);// WAIT 5 SEC
Serial.write(messageE, sizeof(messageE));// SERIAL WRITE MESSAGE E
}
// THIS SCETCH NOT TESTED YET BEFORE I DON'T GET OK FROM THE COMMUNITY BUT 
// MESSAGE A,B,C,D WAS TESTED SUCCESSFUL .
// MESSAGE E NOT TESTED YET

Thanks to all who help if I can I will distribute many karmas or when can I distribute some? :art:
greetings D3TONATOR

ast but no least will my e-scooter and apartment burn down if I connect the Nano ?

Nobody in their right mind would answer “no” to that, due to liability issues.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.