RGB Shield Issue

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Bigjeep093
 
Posts: 9
Joined: Wed Feb 20, 2013 11:13 pm

RGB Shield Issue

Post by Bigjeep093 »

I know this has been posted, and I have searched through several posts and never found a direct solution or answer.

I have the (everything purchased from Adafruit, great prices and fast shipping!) Adruino Uno R3, running Adruino 1 app. I had originally purchased just the 16x2 blue/white LCD. I had it connected and worked with learning the Uno. Had the "Hello World" working fine, then after a few days of playing with code, buttons and relays. I went back to the display and was unable to get it to work, the backlight would light if 5v was applied directly, but nothing on the screen. I figured something happened to the screen.

so I purchase the RGB shield with the monochrome blue/white 16x2 screen (I just like the blue and white and its all I need) I am fairly experienced in soldering and working with PCB's. The assembly was smooth and simple. uploaded the RGB sample, making sure I renamed the library correctly. the only thing that happens is the backlight flashes for a second.

So I went back and double checked all my soldiers, and removed the wires that I had originally installed ( I plan on using it detached, and didn't realize I only needed 4 wires,) checked the board with a volt meter, I have 5v at the power on the shield, and checked the resistors are all correct and working correctly. I traced out a few paths on the board and voltage is there, pin 1 ground, pin 2 5v.

I know the sample sketch is for the RGB screen, I tried changing the backlight to all WHITE with no change, then I tried to change to ON
lcd.Backlight(ON). But it fails to verify. Stating ON was not declared.

I am at a loss, please help. thanks. I have pics of the board but it won't let me upload, get error invalid type. they are just JPG files.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RGB Shield Issue

Post by adafruit_support_rick »

Your jpegs might be too big? Try resizing them to around 800X600.
If you post your code, we'll se if we can't figure out why it won't compile. Paste your code inside the code tags.

Bigjeep093
 
Posts: 9
Joined: Wed Feb 20, 2013 11:13 pm

Re: RGB Shield Issue

Post by Bigjeep093 »

The code is basically the sample code, but I removed the button segment, just wanting to test the LCD, and changed WHITE to ON. Thats when the error message comes "ON was not declared in this scope"

Code: Select all

/*********************

Example code for the Adafruit RGB Character LCD Shield and Library

This code displays text on the shield, and also reads the buttons on the keypad.
When a button is pressed, the backlight changes color.

**********************/

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can't use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7

void setup() {
  // Debugging output
  Serial.begin(9600);
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);

  // Print a message to the LCD. We track how long it takes since
  // this library has been optimized a bit and we're proud of it :)
  int time = millis();
  lcd.print("Hello, world!");
  time = millis() - time;
  Serial.print("Took "); Serial.print(time); Serial.println(" ms");
  lcd.setBacklight(ON);
}

uint8_t i=0;
void loop() 
{
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);

}
Attachments
Shield3.JPG
Shield3.JPG (59.28 KiB) Viewed 1952 times
Shield2.JPG
Shield2.JPG (60.63 KiB) Viewed 1952 times
Shield1.JPG
Shield1.JPG (72.36 KiB) Viewed 1952 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RGB Shield Issue

Post by adafruit_support_rick »

Right. There is no symbol 'ON'. Just use 'WHITE'. Although, I think your backlight maps to RED.

Does the shield work at all? Or is it just the backlight that doesn't work?

The backlight is going to be pin 16 on the LCD (next to the two empty holes). It is driven by pin 27 of the MCP23017.

Check for 5V at pin 27 when you think the LED should be on.

Also, check for continuity. You should measure 220 Ohms between display pin 16 and MCP23017 pin 27.

Bigjeep093
 
Posts: 9
Joined: Wed Feb 20, 2013 11:13 pm

Re: RGB Shield Issue

Post by Bigjeep093 »

right now all I get is the backlight flashes on for a millisecond when I plug in the arduino. I will check those pins when I get home this evening. I have the unit with me at work, but not a volt meter. thanks for the help so far!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RGB Shield Issue

Post by adafruit_support_rick »

Your pictures didn't include a shot of the front. Are you sure the MCP23017 is in the right way?
Also, are you sure you've got SDA and SCL connected to the arduino the right way, and not reversed?

Bigjeep093
 
Posts: 9
Joined: Wed Feb 20, 2013 11:13 pm

Re: RGB Shield Issue

Post by Bigjeep093 »

Here is a pic of the front, I made sure the notch was facing to the right.

As I look at it, and the drawing from the instruction, I notice that the ground wire on the shield is using the 1st ground, skips the next ground on the UNO then the power 5v.

I have mine connected to the 2nd ground, and the 5v, On my pic, you see the red, and black together, those are the power, (RED) and ground (BLACK) then I have, on the far right, the last pin, GREEN to A5 and BLACK to A4

The ground pin I am using does line up if you use it as a stack, but is it really connected to anything? Do I need move my ground over to the other pin?
Attachments
RGB_LCD_WIRING_rev1.png
RGB_LCD_WIRING_rev1.png (460.4 KiB) Viewed 1927 times
Shield4.JPG
Shield4.JPG (89.89 KiB) Viewed 1927 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RGB Shield Issue

Post by adafruit_support_rick »

The ground pin is fine where it is.

Do any characters show up? Is it just the backlight that doesn't work?

Bigjeep093
 
Posts: 9
Joined: Wed Feb 20, 2013 11:13 pm

Re: RGB Shield Issue

Post by Bigjeep093 »

I moved the ground pin over one pin and it works perfectly now.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RGB Shield Issue

Post by adafruit_support_rick »

Bigjeep093 wrote:I moved the ground pin over one pin and it works perfectly now.
By Gum, you are right! I just checked my shield, and there's NO continuity between the two GND pins. :shock:

The schematic shows no connection to the left GND pin, but I assumed that was just a mistake in the drawing. Guess not. When you assume… etc.:roll:

Bigjeep093
 
Posts: 9
Joined: Wed Feb 20, 2013 11:13 pm

Re: RGB Shield Issue

Post by Bigjeep093 »

I hate to start a new topic so I am just going to add to this one.

The screen and buttons do function as they should when using the sample "HELLO WORLD" sketch.

but I am looking to call the buttons for other functions. e.g:

Code: Select all

___________________

int relay2 = 2;     // set relay 2 at pin 2

pinMode(relay2, OUTPUT);    // set relay2 on pin 2 as output

if (BUTTON_UP == HIGH)
          { 
          if (relay2 == LOW);
              digitalWrite(relay2, HIGH);
           }

              else
               digitalWrite(relay2, LOW);
            }
                
But honestly I can't get a grip on the button command. I know using the shield makes it a little different, which me being a noob is throwing me off.

in a nut shell what I want is simple code that a button turns on and off a relay connected to a pin, declared as an INT.

right now I have some code written, but the relays come on at start, and if I press a button one goes off and wont come back on, and if I press another button, that relay only goes on and off momentary (with the button pressed its on, let go its off) but then the OTHER relay goes off.

I am lost.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RGB Shield Issue

Post by adafruit_support_rick »

Code: Select all

          if (relay2 == LOW);
              digitalWrite(relay2, HIGH);
relay2 is a pin number, not the logic state of that pin. To get the logic state, you need to read the pin. Same thing goes for BUTTON_UP. You don't show that part of the code, but I'm going to guess that BUTTON_UP is a pin number. Try this:

Code: Select all

if (digitalRead(BUTTON_UP) == HIGH)
          { 
          if (digitalRead(relay2) == LOW);
              digitalWrite(relay2, HIGH);
           }

              else
               digitalWrite(relay2, LOW);
            }
But really, assuming that the logic you posted here is what you really want, you could replace all that code with just this:

Code: Select all

digitalWrite(relay2, digitalRead(BUTTON_UP));

BTW, regarding starting a new topic: We often miss posts when people decide to just tack their questions onto the end of an old topic. It's much easier for us to spot new topics with 0 replies.

Bigjeep093
 
Posts: 9
Joined: Wed Feb 20, 2013 11:13 pm

Re: RGB Shield Issue

Post by Bigjeep093 »

Thanks for the reply and understand your point about seeing 0 replies.

Here is more of my code. I didn't declare the buttons, they are from the RGB LCD shield example HELLO WORLD. I was just attempting to use that and modify to fit my needs. I know that the the buttons on the shield are not digital, the return a value, not HIGH LOW, so I just used the sample and modified it. instead of just printing UP, I want to turn pins on or off. Hope that clears up where I got the button code from.

but I do understand the getting the logic state of the relay pin.

Code: Select all

// include the library code:
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <OneWire.h>

// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can't use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

uint8_t i=0;

void loop() 
{
  
  uint8_t buttons = lcd.readButtons();

  if (buttons) 
{    
    if (buttons & BUTTON_UP)   // Button UP is TEMP UP
    {
      lcd.print("UP ");
    }
    
    if (buttons & BUTTON_DOWN)    // Button DOWN is TEMP DOWN 
    {
      lcd.print("DOWN ");
    }
    
    if (buttons & BUTTON_LEFT)    // Button LEFT is PUMP 1, relay 2
    {
       if (relay2 == LOW);
           digitalWrite(relay2, HIGH);
    }
       else
           digitalWrite(relay2, LOW); 
    }
    
    if (buttons & BUTTON_RIGHT)    // Button RIGHT is PUMP 2, relay 3
    {
      if (relay3 == LOW);
           digitalWrite(relay3, HIGH);
    }
       else
           digitalWrite(relay3, LOW); 
   
       if (buttons & BUTTON_SELECT)    // Button SECLECTis LIGHT, relay 4
    {
      if (relay4 == LOW);
           digitalWrite(relay4, HIGH);
    }
       else
           digitalWrite(relay4, LOW);  
    
}



User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: RGB Shield Issue

Post by adafruit_support_rick »

Bigjeep093 wrote:I didn't declare the buttons, they are from the RGB LCD shield example HELLO WORLD.
Ah. OK. Well, you've still got an extra close brace in there. And you don't want to put a semicolon after your ifs. That just makes them not do anything

Code: Select all

    if (buttons & BUTTON_LEFT)    // Button LEFT is PUMP 1, relay 2
    {
       if (digitalRead(relay2) == LOW)    //;  no semicolon!
           digitalWrite(relay2, HIGH);
    }
       else
           digitalWrite(relay2, LOW); 
//    } doesn't pair with anything
    
    if (buttons & BUTTON_RIGHT)    // Button RIGHT is PUMP 2, relay 3
    {
      if (digitalRead(relay3) == LOW)    //;  no semicolon!
           digitalWrite(relay3, HIGH);
    }
       else
           digitalWrite(relay3, LOW); 
   
       if (buttons & BUTTON_SELECT)    // Button SECLECTis LIGHT, relay 4
    {
      if (digitalRead(relay4) == LOW)    //;  no semicolon!
           digitalWrite(relay4, HIGH);
    }
       else
           digitalWrite(relay4, LOW);  
    
}
But you really don't need the if (digitalRead(...) at all. Just do this:

Code: Select all

    if (buttons & BUTTON_LEFT)    // Button LEFT is PUMP 1, relay 2
            digitalWrite(relay2, HIGH);
       else
           digitalWrite(relay2, LOW); 

    if (buttons & BUTTON_RIGHT)    // Button RIGHT is PUMP 2, relay 3
           digitalWrite(relay3, HIGH);
       else
           digitalWrite(relay3, LOW); 
   
    if (buttons & BUTTON_SELECT)    // Button SECLECTis LIGHT, relay 4
           digitalWrite(relay4, HIGH);
       else
           digitalWrite(relay4, LOW);

Bigjeep093
 
Posts: 9
Joined: Wed Feb 20, 2013 11:13 pm

Re: RGB Shield Issue

Post by Bigjeep093 »

Ok, that didn't work. I think the issue is with using the shield buttons. I know that they are analog read, but thought the IC2 did the math and only returned what was pushed. the other issue was that using those buttons, and the RGB shield library ALL the buttons are read when one is pushed. so what would happen is I press button LEFT, it would turn on or off the relay. BUT it would also read the other buttons, so Button RIGHT would act like it was pressed too. So I don't think I can use those buttons. (well at my current knowledge level and skill of programming, lol).

So, change it to make it work. here is the basics, I press a button, I need a relay to come on or go off. even more basic, when an input is HIGH, then check a set OUTPUT for HIGH or LOW, then do the opposite. One would like its as simple as turning a light on and off. Oh wait it is!!

Here is what I have. it "SORT OF" worked. but it was random, if you press the button, the led would turn off, sometimes, and sometimes it would turn on. no set pattern. I think it might be timing, reading the button state. I guess.

what I have here is just a button to turn on the onboard led. but it doesn't say on, so this won't keep a relay on either. How can I write if button (on a pin, set as INPUT) is pressed, to turn on pin (set as OUTPUT) to HIGH and stay HIGH until the button is pressed again. I thought this was it, but like I said the LED doesnt stay on.

Code: Select all

const int buttonPin = 2;
const int ledPin =  13;

int buttonState = 0;

void setup() 
{
  pinMode(ledPin, OUTPUT);      
  pinMode(buttonPin, INPUT);     
}

void loop()
{

  if (digitalRead(buttonPin) == HIGH)  // button is pressed
  {   
      if (digitalRead(ledPin) == LOW)  // see if the LED is on or off, if it is HIGH skip to else
      digitalWrite(ledPin, HIGH);        // if it is LOW turn to HIGH
  } 
  else                                               // if above is not true then do this 
  {
      digitalWrite(ledPin, LOW);         //  turn LED to LOW
  }
}
I must be close. what am I missing?

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”