Shahariar
Published © CC BY

Badge of Hope: Awareness Against Drug Abuse

It's not only a cool little badge with a tiny bubble display for nice words and numbers but also a dev board for prototyping.

BeginnerFull instructions provided8 hours623

Things used in this project

Hardware components

Bubble Display 7 Seg
×1
Microchip Technology Atmega32A
×1
SparkFun LiPo Battery
×1
SparkFun Dip switch
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×3
Capacitor 10 µF
Capacitor 10 µF
×1
Capacitor 100 nF
Capacitor 100 nF
×3
Resistor 10k ohm
Resistor 10k ohm
×8
Male Header 40 Position 1 Row (0.1")
Male Header 40 Position 1 Row (0.1")
×1
4 x 6 cm green protoboard
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Badge Sch

Code

Badge code

C/C++
#include "SevSeg.h"   // https://github.com/sparkfun/SevSeg

SevSeg BubbleDisp;

unsigned long timer;
int deciSecond = 0;

void setup()
{

Bubble_Disp_Init();
delay(200);

}

void loop()
{
  char Word1[5] = {'S','A','Y',' '}; 
  char Word2[5] = {' ','n','o',' '};
  char Word3[5] = {' ','t','o',' '};
  char Word4[5] = {'d','r','u','9'};
  char Word5[5] = {'Y','E','S',' '};
  char Word6[5] = {'L','I','F','E'};
  char Word7[5] = {' ',' ',' ',' '};
  
  
// SAY no to drug
  BubbleDisp_DisplayText(Word1, 0); 
  BubbleDisp_DisplayText(Word2, 0);
  BubbleDisp_DisplayText(Word3, 0);
  BubbleDisp_DisplayText(Word4, 0);

// space
  BubbleDisp_DisplayText(Word7, 0);

// SAY yes to LIFE
  BubbleDisp_DisplayText(Word1, 0); //(numberToDisplay, decimal point location)
  BubbleDisp_DisplayText(Word5, 0);
  BubbleDisp_DisplayText(Word3, 0);
  BubbleDisp_DisplayText(Word6, 0);

// space
  BubbleDisp_DisplayText(Word7, 0);
  BubbleDisp_DisplayText(Word7, 0);

  //read ADC
  //int k= analogRead(40);
  //BubbleDisp_DisplayNumber(k,0); // sent 4 digit number and decimal point
   
}
// loop ends here



///////////// disp functions ///////////////

void Bubble_Disp_Init(void)

{
   int displayType = COMMON_CATHODE; 

  
       //This pinout is for a bubble dispaly
       //Declare what pins are connected to the GND pins (cathodes)
       int digit1 = 21; 
       int digit2 = 12; 
       int digit3 = 18; 
       int digit4 = 16; 
       
       //Declare what pins are connected to the segments (anodes)
       int segA = 22; 
       int segB = 23; 
       int segC = 19; 
       int segD = 13; 
       int segE = 20; 
       int segF = 15; 
       int segG = 14; 
       int segDP= 17; 
   
  int numberOfDigits = 4; // 4 digit display

  BubbleDisp.Begin(displayType, numberOfDigits, digit1, digit2, digit3, digit4, segA, segB, segC, segD, segE, segF, segG, segDP);
  
  BubbleDisp.SetBrightness(100); // 100% brightness level
 
}



void BubbleDisp_DisplayNumber (int number, int dp)
{
    char tempString[10]; //Used for sprintf
  sprintf(tempString, "%4d", number); //Convert number into a string
   for(int i =0;i<100;i++)
  {

 BubbleDisp.DisplayString(tempString, dp); //(number, decimal point)
  } 
}

void BubbleDisp_DisplayText (char text[], int dp)
{
   for(int i =0;i<100;i++)
  {
  BubbleDisp.DisplayString(text, 0); //(numberToDisplay, decimal point location)
  }
}

////////////////////////////////////////////
//////// Atmega32A Dev Board Pinout ////////
////////////////////////////////////////////
// pin num - pin name - Ardu pin --  Func //
//    1        PB0          0        D IO //   
//    2        PB1          1        D IO //           
//    3        PB2          2        INT2 //           
//    4        PB3          3        PWM  //          
//    5        PB4          4        SS   //         
//    6        PB5          5        MOSI //           
//    7        PB6          6        MISO //          
//    8        PB7          7        SCLK //        
//    9        RST                   RST  //                       
//    10       VCC                   VCC  //         
//    11       GND                   GND  //         
//    12       XTL                   XTAL //           
//    13       XTL                   XTAL //           
//    14       PD0          8        RX 0 //           
//    15       PD1          9        TX 0 //          
//    16       PD2          10       INT0 //           
//    17       PD3          11       INT1 //           
//    18       PD4          12       PWM  //          
//    19       PD5          13       PWM  //          
//    20       PD6          14       PWM  //         
//    21       PD7          15       PWM  //          
//    22       PC0          16       SCL  //        
//    23       PC1          17       SDA  //          
//    24       PC2          18       D IO //           
//    25       PC3          19       D IO //           
//    26       PC4          20       D IO //           
//    27       PC5          21       D IO //           
//    28       PC6          22       D IO //           
//    29       PC7          23       D IO //           
//    30       VCC                   VCC  //          
//    31       GND                   GND  //          
//    32       REF                   AREF //           
//    33       PA7          31/28    ADC7 //          
//    34       PA6          30/29    ADC6 //           
//    35       PA5          29/27    ADC5 //           
//    36       PA4          28/26    ADC4 //           
//    37       PA3          27/25    ADC3 //           
//    38       PA2          26/24    ADC2 //           
//    39       PA1          25/31    ADC1 //           
//    40       PA0          24/30    ADC0 //       
////////////////////////////////////////////
///// CODE ACCEPTS ARDUINO PIN NUMBER //////
// Pin numbering depends on board.txt //////
////////////////////////////////////////////

Credits

Shahariar

Shahariar

55 projects • 184 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"
Thanks to Dean Reading.

Comments