Bar Graph

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Re: Bar Graph

Postby pburgess » Mon Jul 02, 2012 11:58 pm

Yeah, I was afraid it might be kind of daunting. Interrupts are sort of a "level 3" topic.

You may be able to fudge something in the interim. For example, you might add an extra equivalent pause to each delay() call, or you might do the screen refresh on each step of the LEDs. This isn't optimal (the maximum blink speed will be much slower), but the timing will be more consistent.
User avatar
pburgess
 
Posts: 1408
Joined: Sun Oct 26, 2008 1:29 am

Re: Bar Graph

Postby WingZero98579 » Tue Jul 03, 2012 12:01 am

OK I'll try those options and see how it goes thank you for your help
WingZero98579
 
Posts: 18
Joined: Mon Jun 11, 2012 12:38 pm

Re: Bar Graph

Postby WingZero98579 » Tue Jul 03, 2012 12:28 am

OK i think i got it going so far. I had to put a delay of 400 in every LED cluster and remove the very last sensor delay. They are scrolling alot slower but it does work.

Code: Select all
#define OLED_DC 11
    #define OLED_CS 12
    #define OLED_CLK 10
    #define OLED_MOSI 9
    #define OLED_RESET 13

    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

    Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

    int sensorPin = A0; // select the input pin for the potentiometer
    //int ledPin = 13; // select the pin for the LED
    int sensorValue = 0; // variable to store the value coming from the sensor



    void setup(){

    display.begin(SSD1306_SWITCHCAPVCC);
      // init done
     
      display.display(); // show splashscreen
      delay(10);
      display.clearDisplay();   // clears the screen and buffer
      delay(10);
     
      display.setTextSize(5);
      display.setTextColor(WHITE);
      display.println("KITT");
      display.display();
      delay(10);
     


       pinMode(6, OUTPUT);
       pinMode(5, OUTPUT);
       pinMode(4, OUTPUT);
       pinMode(3, OUTPUT);
       pinMode(2, OUTPUT);
       pinMode(1, OUTPUT);
       pinMode(0, OUTPUT);

    }


    void loop()
    {
              // Read analog input:
    sensorValue = analogRead(sensorPin);
    // Scale input to width of display:
    int w = map(sensorValue, 0, 1023, 0, display.width());
       // Draw filled part of bar starting from left of screen:
    display.fillRect(0, 0, w, display.height(), 1);
       // Erase the area to the right of the bar:
    display.fillRect(w, 0, display.width() - w, display.height(), 0);
    // Update the screen:
    display.display();



       sensorValue = analogRead(sensorPin);
       digitalWrite(3, LOW);
       digitalWrite(4, HIGH);
       digitalWrite(2, HIGH);
       delay(sensorValue);
       delay(400);
       sensorValue = analogRead(sensorPin);
       digitalWrite(4, LOW);
       digitalWrite(2, LOW);
       digitalWrite(5, HIGH);
       digitalWrite(1, HIGH);
       delay(sensorValue);
       delay(400);
       sensorValue = analogRead(sensorPin);
       digitalWrite(5, LOW);
       digitalWrite(1, LOW);
       digitalWrite(6, HIGH);
       digitalWrite(0, HIGH);
       delay(sensorValue);
       delay(400);
       sensorValue = analogRead(sensorPin);
       digitalWrite(6, LOW);
       digitalWrite(0, LOW);
       digitalWrite(1, HIGH);
       digitalWrite(5, HIGH);
       delay(sensorValue);
       delay(400);
       sensorValue = analogRead(sensorPin);
       digitalWrite(1, LOW);
       digitalWrite(5, LOW);
       digitalWrite(2, HIGH);
       digitalWrite(4, HIGH);
       delay(sensorValue);
       delay(400);
       sensorValue = analogRead(sensorPin);
       digitalWrite(2, LOW);
       digitalWrite(4, LOW);
       digitalWrite(3, HIGH);
       
       
    }
WingZero98579
 
Posts: 18
Joined: Mon Jun 11, 2012 12:38 pm

Previous

Return to Glowy things (LCD, LED, TFT, EL) purchased at Adafruit

Who is online

Users browsing this forum: No registered users and 7 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [113]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
BeagleBone[23]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]