#include <LiquidCrystal.h>
//assign pin
#define TX_DATA 17
#define RS_PIN 8
#define E_PIN 9
#define LCD_4 4
#define LCD_5 5
#define LCD_6 6
#define LCD_7 7
//sending speed 5 bit per sec
#define TX_RATE 5
//Message to send
const char *message = "Hello World";
void setup() {
pinMode(TX_DATA, OUTPUT);
LiquidCrystal lcd(RS_PIN, E_PIN, LCD_4, LCD_5, LCD_6, LCD_7);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(message);
for(int byte_idx = 0; byte_idx < strlen(message); byte_idx++) {
//get the one char at the tick from message
char tx_byte = message[byte_idx];
//clear the second line
lcd.noCursor();
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(byte_idx, 0);
lcd.cursor();
for(int bit_idx = 0; bit_idx < 8; bit_idx++) {
//and oparetion byte with each bit to send the data of each bit
bool tx_bit = tx_byte & (0x80 >> bit_idx);
digitalWrite(TX_DATA, tx_bit);
//update LCD
lcd.noCursor();
lcd.setCursor(bit_idx, 1);
lcd.print(tx_bit ? "1" : "0");
lcd.setCursor(byte_idx, 0);
lcd.cursor();
delay(1000/TX_RATE);
}
}
}
void loop() {
}