smile_bmp was not declared in this scope

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
mh512
 
Posts: 76
Joined: Wed Nov 13, 2013 4:06 pm

smile_bmp was not declared in this scope

Post by mh512 »

Stuck on this one:

Code: Select all

// Include required libraries
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
#include "DHT.h"
#include<stdlib.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"



// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ   3
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10

// WiFi network settings
#define WLAN_SSID       "TP-LINK AP"
#define WLAN_PASS       "password"
#define WLAN_SECURITY   WLAN_SEC_WPA2

// DHT11 & I2C LCD configuration
#define DHTPIN 2 
#define DHTTYPE DHT11
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);


// Create CC3000 & DHT instances
DHT dht(DHTPIN, DHTTYPE);
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
                                         
// Local server IP, port, and repository
uint32_t ip = cc3000.IP2U32(192,168,0,100);
int port = 80;
String repository = "/";



// Setup routine                                         
void setup(void)
{
 lcd.begin(16,2);
  dht.begin();
  Serial.begin(115200);
  
  matrix.begin(0x70);  // pass in the address
  
    static const uint8_t PROGMEM
  smile_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10100101,
    B10011001,
    B01000010,
    B00111100 },
   frown_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10011001,
    B10100101,
    B01000010,
    B00111100 };
    
  
    lcd.setCursor(0, 0);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(F("Initialising...")); 
       
  // Initialise the CC3000 module
  if (!cc3000.begin())
  {
    while(1);
  }

    lcd.setCursor(0,1);
    lcd.clear();
    lcd.print(F("Connecting..."));

  // Connect to  WiFi network
  cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
 
    
  // Check DHCP
  
  while (!cc3000.checkDHCP())
  {
    delay(100);
  }  
  
  lcd.setCursor(0,1);
  lcd.clear();
    lcd.print(F("Connected!"));
    
  
    
  
}



void loop(void)
{
   
matrix.clear();
  matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
  matrix.writeDisplay();
  
  
    // Measure the humidity & temperature
    float h = dht.readHumidity();
    float t = dht.readTemperature();
   
      
    // Transform to String
    String temperature = String((int) t);
    String humidity = String((int) h);
    
   
    
    // Send request
    
    
    String request = "GET "+ repository + "submit.php?temp=" + temperature + "&hum=" + humidity + " HTTP/1.0";

    send_request(request);
    
    // Update every second
    delay(1000);
}

// Function to send a TCP request and get the result as a string
void send_request (String request) {
     
    // Connect    
    Adafruit_CC3000_Client client = cc3000.connectTCP(ip, port);
    
    // Send request
    
      client.println(request);      
      client.println(F(""));
      
   

    while (client.connected()) {
      while (client.available()) {

      // Read answer
      char c = client.read();
      }
    }
   
    client.close();
    
}

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: smile_bmp was not declared in this scope

Post by pburgess »

smile_bmp is declared within setup(), limiting its scope to just that function. Move those declarations up above the function (following the 'repository' line) and that should improve the situation.

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

Return to “Other Arduino products from Adafruit”