Pages: [1]   Go Down
Author Topic: Due and the LCS1602  (Read 414 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I've been freakin around with the LCS1602 by sainsmart. The board is also from that provider and did not show any incompatibilites so far.
Now I wanted to check out the LCS1602 provided with the Starter Pack and recogniced some weired stuff in arduino and the documentation.
First of all The LiquidChrystal Library seems not to work with that display.
2nd) the docs that come with the starter kit seem also not to be ok.
They pin BA BK to pins on the arduino board, where the Due is 3,3V and the LCD is 5V. They refer to an 4 bit use, but circuiting is 8 bit.
So:
1) BA have to be connected to 5V Sourcem BK to GND. Both of them to the external 5V source
2) D0-D3 have to be connected to GND (4 Bit mode)
3) VO has to be connected to a 10kOHM variable Resistor
4) the LyquidChrystal Library seems not to be working for that Display

I will check their example tomorrow and try to figure out their wiring, since that can not be reas clear from their guide, only from reviewung their examples.

Hopefully somebody else will repackage their examples (if right) into a library ready for use.

I hope our cracks can give us additional information about that LCD
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I rewired everything from scratch. Now the library works for me.
The follwing example demonstrates the usage of PWM, interrupts, debouncing and the LCD library.
If you read the comments no wiring diagram will be requiered, since its selfexplaining:

//Start of foreign Code
// input pin to debounce, pin 24 is on PORT A

// get bitmask for register manipulation
int mask_1 = digitalPinToBitMask(50);
int mask_2 = digitalPinToBitMask(48);
int mask_3 = digitalPinToBitMask(46);
int mask_4 = digitalPinToBitMask(44);


 
  // activate input filters for pin 24
//  REG_PIOA_IFER = mask_1;
  // choose debounce filter as input filter for pin 24
//  REG_PIOA_DIFSR = mask_1;
  // set clock divider for slow clock -> rejects pulses shorter than (DIV+1)*31µs and accepts pulses longer than 2*(DIV+1)*31µs
//  REG_PIOA_SCDR = 1000;


// End of foreign Code

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(49,45, 35, 33, 31, 29);
//rs,E,DB4-7
//BA +5V, BK GND, VO wisher of Poti, RW GND, VDD 5V, VSS GND


byte red=0;
byte green=0;
byte blue=0;
boolean changed=true;

void setup() {
pinMode(50, INPUT); //resetbutton
pinMode(48, INPUT); //red button
pinMode(46, INPUT); //green button
pinMode(44, INPUT); //blue button
// following is denoising stuff (debouncing)
REG_PIOC_IFER = mask_1;
REG_PIOC_DIFSR = mask_1;
REG_PIOC_SCDR = 1000;
REG_PIOC_IFER = mask_2;
REG_PIOC_DIFSR = mask_2;
REG_PIOC_SCDR = 1000;
REG_PIOC_IFER = mask_3;
REG_PIOC_DIFSR = mask_3;
REG_PIOC_SCDR = 1000;
REG_PIOC_IFER = mask_4;
REG_PIOC_DIFSR = mask_4;
REG_PIOC_SCDR = 1000;



pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(9, OUTPUT);

attachInterrupt(50, resetto0, RISING);
attachInterrupt(48, incrred, RISING);
attachInterrupt(46, incrgreen, RISING);
attachInterrupt(44, incrblue, RISING);
lcd.begin(16, 2);

}
void resetto0() {
  red=0;
  green=0;
  blue=0;
  changed=true;
  }
  \
void incrred() {
    red++;
  changed=true;
  }
void incrgreen() {
   green++;
   changed=true;
   }
void incrblue() {
  blue++;
   changed=true;
   }
   
void loop() {
  if ( changed==true)
  {
    noInterrupts();
    analogWrite(9, red);
    analogWrite(6, green);
    analogWrite(7, blue);
    changed=false;
    interrupts();
    Serial.begin(57600);
    Serial.println(red);

    lcd.clear();
    lcd.setCursor(0, 1);
    lcd.print(millis());
    lcd.setCursor(0, 0);
    lcd.print(red);
    lcd.setCursor(5, 0);
    lcd.print(green);
    lcd.setCursor(11,0);
    lcd.print(blue);
    }
   
   
 
}
Logged

Pages: [1]   Go Up
Jump to: