Error setting up serial communication

groundFungus, i recieved my response in 1 word, i didnt need to provide any additional details, and it solved my problem.

LarryD, sorry about that, obvioulsly im cantakerous enough i dont generally fit in with communities to begin with. but, you have my heart there.

No idea what that means

Calibrated.

well, since im entirely sidetracked to begin with.

i need to learn proper syntax just to ask a question, its akin to learning a new language just to ask a question. when all you want is an answer, since the code was simple enough, a screenshot took 2 seconds, provided every bit of detail that was required. rather effecient i thought.

as far as being a wanker, well, i coulda told you that, i didnt need to learn that from a forum. :wink:

Most of us here are.

#include <LiquidCrystal_I2C.h> //Import the LCD library
LiquidCrystal_I2C lcd(0x27,20,4); //set the pins outputting to lcd

int mode = 0;
byte recieve[1] = {0};


void setup() {

  
  lcd.init(); 
  lcd.backlight();
  lcd.clear();

  Serial.begin(9600);


}//end setup

void loop() {
switch(mode){
  case 0:
    
    Serial.readBytes(recieve,1);

delay(500);
  lcd.setCursor(0,0);
  lcd.print(recieve[1]);
delay(500);
  break;
}//end switch(mode)
}//end loop

since were here, i am having an odd issue, the screen is displaying 4, instead of 0, and im not sure why.

A one element array has no index 1

(sp. "receive")

oh, starts with 0, ofcourse, makes sense.

BTW

For better readability, format your sketches.

In the Arduino IDE, use Ctrl T or CMD T to format your code.

im using 32 bit linux on an old pc as a coding machine, im assuming that formatting requires 64bit java? because i am unable to format my code in the IDE on this machine.

Sorry, crappy Windoz here.

:sleepy:

If you're unable to autoformat (never heard of that), you should get into the habit of formatting as you code.

eh, i dont mind windows, this computer is so old tho(it came with xp) that it doesnt even load xp well. but, LDXE linux enviroment runs decent for most of what i use this for. (its very light.)

I just dont want to move my workbench near my computer and viceversa. so, its handy to have this dinosaur to type on.

yeah, im not sure, it pretends to format, but, never actually moves any text.

it would behoove me to be more consistent when typing, i guess the addage of lazy programming is true. (i guess its probably cause theres so many thoughts going on, its just easier to dump what you can, or something)

I still use Windows 95 on my CNC machine, and have two backup 95 machines just in case.

:nerd_face:

good ol '95, just moments before windows became bloatware, nice.

I can remember Bill Gates trying to demo Win 95 in a packed auditorium. Could not get it to work.
Paul

IMO 95 was/is very stable.

I’ve run my CNC for many many hours with zero problems.

I’ve had to change the RTC battery on the 95 computers twice :mantelpiece_clock:


OMG 26 YEARS

okay, apparently this is proving more complicated than it aught to. The transmitter is printing a 7 just fine, and the TX light is blinking every second accordingly. The receiving unit does not print the variable like its supposed to, the RX light does not light.(assuming it is just not receiving, as it just displays "-1")

Wiring is lcd is to scl/sda for the lcd screen, and TX and RX are hooked up crossed like they aught to, with a common ground.(its why im using the mega2560 as it has both scl/sda and tx/rx that arent the same pinouts.)

The receiving unit is a mega2560
The sending unit is a nano, ATmega328P

Receiver code:

#include <LiquidCrystal_I2C.h> //Import the LCD library
LiquidCrystal_I2C lcd(0x27,20,4); //set the pins outputting to lcd

int mode = 0;


int receivedChar;
boolean newData = false;


void setup() {

  
  lcd.init(); 
  lcd.backlight();
  lcd.clear();

  Serial.begin(9600);


}//end setup

void loop() {
switch(mode){
  case 0:
    recvOneChar();
    showNewData();

 break;
}
}


void recvOneChar() {
    //if (Serial.available() > 0) {
        receivedChar = Serial.read();
        newData = true;
        lcd.setCursor(0,0);
        lcd.print(receivedChar);
   // }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChar);
        newData = false;
    }
}

Transmitter code:

int mode = 0;
int send = 7;


void setup() {
Serial.begin(9600);

}//end setup

void loop() {
switch(mode){
case 0:
Serial.print(send);
delay(1000);
break;
}//end switch(mode)
}//end loop

should also note that TX is constant lit on the mega2560

-1 is what Serial read returns when there is nothing to read.