Show Posts
Pages: [1] 2 3 ... 23
1  Using Arduino / Project Guidance / Re: RFID-RC522 on: June 19, 2014, 03:44:41 am
The image you sent, just looks like it contains data rather than a program of some form.

You will need to provide more information about RFID device you are using etc
Hi,

I am using RC522 model.

Thanks!
2  Using Arduino / Project Guidance / RFID-RC522 on: June 18, 2014, 07:30:58 am
Dear all, I started playing around with RFID recently. First of all, I do not understand what actually those code attached in the picture means.

Can anyone explain or show any good link for me ?

Thanks !
3  Using Arduino / Programming Questions / One button to serve different purpose on: March 06, 2014, 11:23:12 am
Dear all,

I am planning to have a menu based system with let say 2 tact switch.

When button 1 is pressed, it enter screen 1.
When it is in screen 1, when I press the same button 1, it will go to screen 2.

How is it possible to do so ?

Thank you.
4  Using Arduino / Programming Questions / Re: A menu with some buttons on: March 05, 2014, 08:36:58 pm
so for example,

i declare the following
Code:
int buttonPins[] ={31,32,33,34,35,36};
int buttonState[] ={0,0,0,0,0,0};
[/code/

31,32,33 are the pins I use on the mega.  I use an array so that I don't have to do so many if statements
the example below is when i go into a menu, I display the options on the screen and then wait for a response, if they don't respond in 10 seconds I break out of the code and go back to the previous or main loop.

[code]
long mil = millis();
 long timer = 0;
lcd.clear();
  lcd.print("Admin Mode:  1-Update");
  lcd.setCursor(0,1);
  lcd.print("2-FreeVend 3-Off");
int thisPin;
  // the array elements are numbered from 0 to (pinCount - 1).
  // use a for loop to initialize each pin as an output:
   int buttonpressed = 0;
     while(buttonpressed < 1){
       timer = millis();
       for (int thisPin = 0; thisPin < drinkPinCount; thisPin++)  {
            buttonState[thisPin] = digitalRead(buttonPins[thisPin]);
            buttonpressed += buttonState[thisPin];          
       }
       if(timer - mil > 10000) {buttonpressed = 1;}    
     }
     if(timer - mil < 10000){
      if (buttonState[0] == HIGH) {    
           lcd.print("Admin Mode: Update");
           lcd.setCursor(0,1);
           lcd.print(RFIDnum);
           delay(500);
        Serial.println("Admin mode 0");
        admintimeout = 0;
        while(admintimeout <1){AddtoCard();}
      }
      if (buttonState[1] == HIGH) {    
           lcd.print("Admin Mode:");
           lcd.setCursor(0,1);
           lcd.print("Free Drink On");
           for (int setcost = 0; setcost < drinkPinCount; setcost++)  {
            drinkCost[setcost] = 0;
           }  
           FreeDrink();
           delay(500);
           Serial.println("Admin mode 1");
        
      }
      if (buttonState[2] == HIGH) {    
           lcd.print("Admin Mode:");
           lcd.setCursor(0,1);
           lcd.print("Free Drink Off");
           soundSad();
           soundSad();
           soundSad();
           delay(1500);
           ReadPrices();
          
        Serial.println("Admin mode 2");
     }
    
  
    }


[/code]
Hi, thanks for the reply. However, I wanted to know is that any possibility if I were to modified my current sketch ?

Thank you.

This is my current code :
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin_1 = 6;     // the number of the pushbutton pin
const int buttonPin_2 = 7;
const int buttonPin_3 = 9;
const int buttonPin_4 = 10;
const int buttonPin_5 = 8;

// variables will change:
int buttonState_1 = 0;         // variable for reading the pushbutton status
int buttonState_2 = 0;
int buttonState_3 = 0;         // variable for reading the pushbutton status
int buttonState_4 = 0;
int buttonState_5 = 0;


void setup() {
  // initialize the LED pin as an output:
   lcd.begin(20, 4);   
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin_1, INPUT);
  digitalWrite(buttonPin_1,HIGH); 
  pinMode(buttonPin_2, INPUT);
  digitalWrite(buttonPin_2,HIGH); 
  pinMode(buttonPin_3, INPUT);
  digitalWrite(buttonPin_3,HIGH); 
  pinMode(buttonPin_4, INPUT);
  digitalWrite(buttonPin_4,HIGH);
 pinMode(buttonPin_5, INPUT);
  digitalWrite(buttonPin_5,HIGH);   
  /*lcd.setCursor(0,0);
   lcd.print("EEE 351");
   lcd.setCursor(0,1);
   lcd.print("Advanced Laboratory");
   lcd.setCursor(0,2);
   lcd.print("March 2014");
   delay(2500);
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Group Members:");
   lcd.setCursor(0,1);
   lcd.print("Lim Chee Keat");
   lcd.setCursor(0,2);
   lcd.print("Teo Kae Hoong");
   lcd.setCursor(0,3);
   lcd.print("Vincent Kok");
   delay(2500);
   lcd.clear();
   lcd.setCursor(5,0);
   lcd.print("Embedded");
   lcd.setCursor(7,1);
   lcd.print("Audio");
   lcd.setCursor(6,2);
   lcd.print("System");
delay(2500);
lcd.clear();
  */
}

void loop(){
 
  // read the state of the pushbutton value:
   buttonState_1 = digitalRead(buttonPin_1);
   buttonState_2 = digitalRead(buttonPin_2);
    buttonState_3 = digitalRead(buttonPin_3);
   buttonState_4 = digitalRead(buttonPin_4);
    buttonState_5= digitalRead(buttonPin_5);

mainmenu();
if (buttonState_1 == LOW)
{
  screen_1();
  mainmenu();
}
else if (buttonState_2 == LOW)
{
  screen_2();
}
else if (buttonState_3 == LOW)
{
  screen_3();
}
else if (buttonState_4 == LOW)
{
  screen_4();
}
}



void mainmenu()
{
  while(true)
  {
  lcd.setCursor(0,0);
lcd.print("Main Menu");
lcd.setCursor(0,1);
lcd.print("1.Manual");
lcd.setCursor(10,1);
lcd.print("2.Preset");
lcd.setCursor(0,2);
lcd.print("3.Volume");
lcd.setCursor(10,2);
lcd.print("4.Info");
return;
}

}

void screen_1()
{
  lcd.clear();
  while(true)
  {
 lcd.setCursor(0,0);
  lcd.print("Manual Selection");
  if (buttonState_5 == LOW)
  {
    return;
  }
 }
}
 
void screen_2()
{
  lcd.clear();
  while(true)
  {
 lcd.setCursor(0,0);
  lcd.print("Preset Setting");
  lcd.setCursor(0,1);
  lcd.print("1.Rock");
  lcd.setCursor(0,2);
  lcd.print("2.Jazz");
  lcd.setCursor(0,3);
  lcd.print("3.Classic");
  }
}

void screen_3()
{
  lcd.clear();
  while(true)
  {
 lcd.setCursor(0,0);
  lcd.print("Volume Control");
  lcd.setCursor(0,1);
  lcd.print("1.UP");
  lcd.setCursor(0,2);
  lcd.print("2.DOWN");
  }
}

void screen_4()
{
  lcd.clear();
  while(true)
  {
 lcd.setCursor(0,0);
  lcd.print("Information");
  lcd.setCursor(2,1);
  lcd.print("Graphic Equalizer");
  lcd.setCursor(8,2);
  lcd.print("V1.0");
 
  }
}
void screen_5()
{
  lcd.clear();
  while(true)
  {
 lcd.setCursor(0,0);
  lcd.print("Screen5");
 
  }
}


5  Using Arduino / Programming Questions / Re: A menu with some buttons on: March 05, 2014, 03:30:38 am
As I suggested, if you use a  variable menuItem, each time you push a switch the new value of the counter is used as a trigger to display a new screen message.
My main question is that in the void screen1 subroutine, how do I jump out from that subroutine since I am using the while(true) loop ?

Thanks !
6  Using Arduino / Programming Questions / Re: A menu with some buttons on: March 05, 2014, 03:24:05 am
As I suggested, if you use a  variable menuItem, each time you push a switch the new value of the counter is used as a trigger to display a new screen message.
I get your idea on using the variable menuitem. But if the variable increasing by 1, how am I gonna to use it for another screen ?

I mean how will be the algorithm for the code ?

Thanks
7  Using Arduino / Programming Questions / Re: A menu with some buttons on: March 05, 2014, 01:53:47 am
So you can do this a couple of ways

Say you have 5 buttons
I would put in the main loop
Check buttons();
Inside check buttons()
I would list all 5 buttons like you did, then do a if (button1 == high){button1menu();}
Then create your button1menu routine.  Inside button1menu(). You can write something to the display and then check button status again.   When I am waiting for  response I use a timer and while statement to see if a button is pressed. Otherwise it will loop right by and you won't get your screen. As you test write to Serial.print and use the serial monitor to see what is happening



Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin_1 = 10;     // the number of the pushbutton pin
const int buttonPin_2 = 9;
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState_1 = 0;         // variable for reading the pushbutton status
int buttonState_2 = 0;
void setup() {
  // initialize the LED pin as an output:
   lcd.begin(20, 4);
  pinMode(ledPin, OUTPUT);     
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin_1, INPUT);
digitalWrite(buttonPin_1,HIGH); 
pinMode(buttonPin_2, INPUT);
digitalWrite(buttonPin_2,HIGH); 
 lcd.setCursor(0,0);
   lcd.print("EEE 351");
   lcd.setCursor(0,1);
   lcd.print("Advanced Laboratory");
   lcd.setCursor(0,2);
   lcd.print("March 2014");
   delay(2500);
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Group Members:");
   lcd.setCursor(0,1);
   lcd.print("Lim Chee Keat");
   lcd.setCursor(0,2);
   lcd.print("Teo Kae Hoong");
   lcd.setCursor(0,3);
   lcd.print("Vincent Kok");
   delay(2500);
   lcd.clear();
   lcd.setCursor(6,0);
   lcd.print("Embedded");
   lcd.setCursor(7,1);
   lcd.print("Audio");
   lcd.setCursor(6,2);
   lcd.print("System");
delay(2000);
lcd.clear();
   
}

void loop(){
  // read the state of the pushbutton value:
   buttonState_1 = digitalRead(buttonPin_1);
   buttonState_2 = digitalRead(buttonPin_2);

mainmenu();
if (buttonState_2 == LOW)
{
  screen_2();
  if (buttonState_2 ==LOW);
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Screen3");
  }
}
}

void mainmenu()
{
  lcd.setCursor(0,0);
lcd.print("Main Menu");
lcd.setCursor(0,1);
lcd.print("1.Manual");
lcd.setCursor(10,1);
lcd.print("2.Preset");
lcd.setCursor(0,2);
lcd.print("3.Volume");
lcd.setCursor(10,2);
lcd.print("4.Info");
}

void screen_2()
{
  lcd.clear();
  while(true)
  {
 lcd.setCursor(0,0);
  lcd.print("Preset Setting");
  lcd.setCursor(0,1);
  lcd.print("1.Rock");
  lcd.setCursor(0,2);
  lcd.print("2.Jazz");
  lcd.setCursor(0,3);
  lcd.print("3.Classic");
  }
}
This is my current coding. I can get into a main menu. And when button 2 is pressed it will go to Preset Setting Menu. And from this menu how can I make that when I press the same button 2, it will go to the third menu ?

Thanks !
8  Using Arduino / Programming Questions / Re: A menu with some buttons on: March 05, 2014, 01:22:12 am
have you tried the Example 'Button' in the Arduino IDE ?
Yes, I tried tat. But I am curious on how to go to other screen under an infinite loop. >.<
9  Using Arduino / Programming Questions / Re: A menu with some buttons on: March 05, 2014, 01:14:05 am
where's the "other" menu ?

and what are you doing with this
Code:
  buttonState_1 = digitalRead(buttonPin_1);
   buttonState_2 = digitalRead(buttonPin_2);
after you've read them ?
I am still trying >.<
10  Using Arduino / Programming Questions / Re: A menu with some buttons on: March 04, 2014, 10:17:58 pm
Show us what you have done.
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin_1 = 10;     // the number of the pushbutton pin
const int buttonPin_2 = 9;
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState_1 = 0;         // variable for reading the pushbutton status
int buttonState_2 = 0;
void setup() {
  // initialize the LED pin as an output:
   lcd.begin(20, 4);
  pinMode(ledPin, OUTPUT);     
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin_1, INPUT);
digitalWrite(buttonPin_1,HIGH); 
pinMode(buttonPin_2, INPUT);
digitalWrite(buttonPin_2,HIGH); 
}

void loop(){
  // read the state of the pushbutton value:
  buttonState_1 = digitalRead(buttonPin_1);
   buttonState_2 = digitalRead(buttonPin_2);

 Mainmenu();
 
 
}
 
 
 
void Mainmenu()
 {
   lcd.setCursor(0,0);
   lcd.print("EEE 351");
   lcd.setCursor(0,1);
   lcd.print("Advanced Laboratory");
   lcd.setCursor(0,2);
   lcd.print("March 2014");
   
   return;
 }
 
11  Using Arduino / Programming Questions / A menu with some buttons on: March 04, 2014, 10:06:50 pm
Dear all, I am doing a project which require a menu. And when I press on a tact switch it will go to another menu.

How can I implement this ?

I tried using if else, but I failed to do so.

Thank you.
12  Using Arduino / General Electronics / Re: Attiny 85 with 3V CR2032 Coin Cell Battery on: February 09, 2014, 09:03:45 am
I never use a resistor instead Hahah
13  Using Arduino / General Electronics / Attiny 85 with 3V CR2032 Coin Cell Battery on: February 09, 2014, 07:38:20 am
Dear all,

Recently I am planning to use attiny 85 powered by a CR2032 coin cell battery to light up some LEDs randomly. I tried to connect them but it seems that the LEDs is actually not that bright.

Any problems/solutions ?

14  Using Arduino / Microcontrollers / Re: Atmega328 vs Atmega328p....what are the differences? on: February 08, 2014, 02:51:48 am
The 2 devices have a different signature. I added the 328 to my Arduino and AVRDude files so that makes it easier to burn a bootloader. Once the bootloader is loaded they are interchangeable in the Uno board so the Uno config is sufficient to program them. I have a couple 328's that I have installed the bootloader on. they have all been in my arduino board and also in a wireless breadboard that has a MAX232 for a serial interface. Once the bootloader is loaded they all function the same with the ArduinoIDE.

Functionally I think the only real difference is in low power operation.

Hi, How do you add the atmega 328 to your arduino and avrdude ? I always need to change the signature when bootloading atmega 328.

Thanks !

My email : vick.kok@live.com
15  Using Arduino / Programming Questions / Re: Sending 16 bits data from Arduino UNO on: February 03, 2014, 08:02:57 am
send them to be received by android phone or wireless.

Thanks !
Pages: [1] 2 3 ... 23