Programación
Programa texto.
include "Charliplexing.h"
#include "Myfont.h"
#include "Arduino.h"
int leng=0; //provides the length of the char array
unsigned char test[]="Proyecto Panel Luminoso Clases \0"; //'\0' es el final de mensaje
- * ----------------------------------------------------------------- */
/** MAIN program Setup
*/
void setup() // run once, when the sketch starts
{
LedSign::Init();
for(int i=0; ; i++){ //asigna en leng la longitud del texto
if(test[i]==0){
leng=i;
break;
}
}
}
- * ----------------------------------------------------------------- */
/** MAIN program Loop
*/
void loop() // run over and over again
{
Myfont::Banner(leng,test);
}
Programa 2 sensor de temperatura.
/******************************************************************
******************************************************************/
/*
* Displays Temperature from TMP36 numerically on an LOL shield
* Adapted from (and for more details on this circuit): https://tinyurl.com/c89tvd
*/
#include "Charliplexing.h"
#include "Myfont.h"
//int value = analogRead(sensorPin);
// float millivolts = (value / 1023.0) * 5000;
// float celsius = millivolts / 10;
//TMP36 Pin Variables
int temperaturePin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade
//(500 mV offset) i.e. 0 degrees = 500mV
const int sensorPin= 0;
char buffer[12];
void setup()
{
LedSign::Init();
Serial.begin(9600); //Start the serial connection with the computer
}
void loop() // run over and over again
{
int value = analogRead(sensorPin);
float millivolts = (value / 1023.0) * 5000;
float temperature = millivolts / 10;
Serial.println(temperature); // printing the result for debug
ltoa(long(temperature), buffer, 10);
for (int i=0; i<2; i++) { // Iterate through the buffer
Myfont::Draw(1+i*6,buffer[i]); // Sending each character to the LOL shield
}
delay(1000); // wait a second
LedSign::Clear(); // Clear the display
}
/*
* getVoltage() - returns the voltage on the analog input defined by
* pin
*/
float getVoltage(int pin){
return (analogRead(pin) * 5.0/1024); //converting from a 0 to 1023 digital range
// to 0 to 5 volts (each 1 reading equals ~ 5 mV)
}
Programa 3 Real Clock Time
/******************************************************************
******************************************************************/
#include <Wire.h>
//#include "RTClib.h"
#include <Rtc_Pcf8563.h>
#include <avr/pgmspace.h>
#include <Charliplexing.h>
int digits[][15] = {
{1,1,1,1,0,1,1,0,1,1,0,1,1,1,1}
,{0,0,1,0,0,1,0,0,1,0,0,1,0,0,1}
,{1,1,1,0,0,1,1,1,1,1,0,0,1,1,1}
,{1,1,1,0,0,1,1,1,1,0,0,1,1,1,1}
,{1,0,1,1,0,1,1,1,1,0,0,1,0,0,1}
,{1,1,1,1,0,0,1,1,1,0,0,1,1,1,1}
,{1,0,0,1,0,0,1,1,1,1,0,1,1,1,1}
,{1,1,1,0,0,1,0,0,1,0,0,1,0,0,1}
,{1,1,1,1,0,1,1,1,1,1,0,1,1,1,1}
,{1,1,1,1,0,1,1,1,1,0,0,1,0,0,1}
};
//RTC_DS1307 RTC;
Rtc_Pcf8563 rtc;
void setup () {
Serial.begin(57600);
Wire.begin();
rtc.initClock();
rtc.formatTime(RTCC_TIME_HM);
rtc.setTime(20, 05, 0);
LedSign::Init(DOUBLE_BUFFER);
}
void loop () {
int h = rtc.getHour();
if (h>12)
{
h=h-12;
}
// first digit of hours
if (h>9)
{
for (int y=2;y<7;y++)
{
LedSign::Set(1,y,1);
}
}
// second digit of hours
for (int i=0;i<15;i++)
{
LedSign::Set((i % 3)+3,(i/3)+2,digits[h%10][i]);
}
// first digit of minutes
for (int i=0;i<15;i++)
{
LedSign::Set((i % 3)+7,(i/3)+2,digits[rtc.getMinute()/10][i]);
}
//second digit of minutes
for (int i=0;i<15;i++)
{
LedSign::Set((i % 3)+11,(i/3)+2,digits[rtc.getMinute()%10][i]);
}
LedSign::Flip();
delay(1000);
}