Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // scrolltext demo for Adafruit RGBmatrixPanel library.
- // Demonstrates double-buffered animation on our 16x32 RGB LED matrix:
- // http://www.adafruit.com/products/420
- // Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon
- // for Adafruit Industries.
- // BSD license, all text above must be included in any redistribution.
- float tempC;
- int tempPin = A5;
- #include <Adafruit_GFX.h> // Core graphics library
- #include <RGBmatrixPanel.h> // Hardware-specific library
- #define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
- #define LAT A3
- #define OE 9
- #define A A0
- #define B A1
- #define C A2
- // Last parameter = 'true' enables double-buffering, for flicker-free,
- // buttery smooth animation. Note that NOTHING WILL SHOW ON THE DISPLAY
- // until the first call to swapBuffers(). This is normal.
- RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
- // Double-buffered mode consumes nearly all the RAM available on the
- // Arduino Uno -- only a handful of free bytes remain. Even the
- // following string needs to go in PROGMEM:
- #define STRING_SIZE 32
- char str[STRING_SIZE]; //the string to scroll
- char tempBuffer[8]; //storage for the temperature substring
- int textX = matrix.width(),
- textMin = sizeof(str) * -12,
- hue = 0;
- void setup() {
- matrix.begin();
- matrix.setTextWrap(false); // Allow text to run off right edge
- matrix.setTextSize(2);
- Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
- }
- uint32_t temptimer = millis();
- void loop() {
- byte i;
- if ((millis() - temptimer) > 3500)
- {
- temptimer = millis();
- tempC = analogRead(tempPin); //read the value from the sensor
- tempC = (5.0 * tempC * 10.0)/1024.0; //convert the analog data to temperature
- Serial.print(tempC); //send the data to the computer
- snprintf(str, STRING_SIZE-1, "Current Temperature is %sC", dtostrf(tempC, 6, 2, tempBuffer));
- }
- // Clear background
- matrix.fillScreen(0);
- matrix.setTextColor(matrix.ColorHSV(hue, 255, 255, true));
- matrix.setCursor(textX, 1);
- matrix.print(str);
- // Move text left (w/wrap), increase hue
- if((--textX) < textMin) textX = matrix.width();
- hue += 7;
- if(hue >= 1536) hue -= 1536;
- // Update display
- matrix.swapBuffers(false);
- delay(15);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement