Last active
February 20, 2022 04:54
-
-
Save spensireli/c01e91a4993e48196655710761ce0000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LiquidCrystal_I2C.h: https://github.com/johnrickman/LiquidCrystal_I2C | |
#include <Wire.h> // Library for I2C communication | |
#include <LiquidCrystal_I2C.h> // Library for LCD using I2C Adapter | |
#include <Firmata.h> | |
// Wiring: SDA pin is connected to A4 and SCL pin to A5. | |
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered) | |
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2); // Change to (0x27,20,4) for 20x4 LCD. | |
int lastLine = 1; | |
void setup() { | |
// Initiate the LCD: | |
lcd.init(); | |
lcd.backlight(); | |
Firmata.setFirmwareVersion( FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION ); | |
Firmata.attach( STRING_DATA, stringDataCallback); | |
Firmata.begin(); | |
} | |
void stringDataCallback(char *stringData){ | |
if ( lastLine ) { | |
lastLine = 0; | |
lcd.clear(); | |
} else { | |
lastLine = 1; | |
lcd.setCursor(0,1); | |
} | |
lcd.print(stringData); | |
} | |
void loop() { | |
lcd.setCursor(2, 0); // Set the cursor on the third column and first row. | |
while ( Firmata.available() ) { | |
Firmata.processInput(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyfirmata import Arduino, util, STRING_DATA | |
board = Arduino('/dev/ttyACM0') | |
board.send_sysex( STRING_DATA, util.str_to_two_byte_iter('Sending some text.') ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LiquidCrystal_I2C.h: https://github.com/johnrickman/LiquidCrystal_I2C | |
#include <Wire.h> // Library for I2C communication | |
#include <LiquidCrystal_I2C.h> // Library for LCD using I2C Adapter | |
#include <Firmata.h> | |
// Wiring: SDA pin is connected to A4 and SCL pin to A5. | |
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered) | |
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2); // Change to (0x27,20,4) for 20x4 LCD. | |
int lastLine = 1; | |
char *lastStringData = NULL; | |
void setup() { | |
// Initiate the LCD: | |
lcd.init(); | |
lcd.backlight(); | |
lcd.setCursor(0, 0); // Set the cursor on the third column and first row. | |
Firmata.setFirmwareVersion( FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION ); | |
Firmata.attach( STRING_DATA, stringDataCallback); | |
Firmata.begin(); | |
} | |
void stringDataCallback(char *stringData){ | |
if ( lastLine ) { | |
lcd.clear(); | |
} else { | |
lastLine = 1; | |
lcd.setCursor(0,1); | |
} | |
lcd.print(stringData); | |
if (lastStringData != NULL) { | |
free(lastStringData); | |
} | |
lastStringData = ( char* ) malloc(strlen(stringData)+1); | |
strcpy(lastStringData, stringData); | |
} | |
void loop() { | |
// Serial.print(lastStringData);Serial.print("-");Serial.println(strlen(lastStringData)); | |
while ( Firmata.available() ) { | |
Firmata.processInput(); | |
} | |
lcd.scrollDisplayLeft(); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment