46Views5Replies

Author Options:

Arduino integration program Answered

Hi. I've got queries about integration of program. I had done some simple program to test/check various modules (LEDs, push button, switch and etc.) functionality. However, i wanna type a program that if i press keypad '1', it will run the LEDs program to check to LEDs. If i press keypad '2', it will run the push button program to check the push button functionality. And so on for other programs.
Anyone out there can help me? If possible type it out for me because i'm really not an Arduino expert. I will upload those simple programs to test/check the modules. So please help me out. Thanks alot !

Tags:Arduino

Discussions

0
None
xianie

5 years ago

Please really help me out. Some simple programs i've posted in the comments below. Please help out.

0
None
xianie

5 years ago

#include Wire.h
#include a_input.h
#include a_delays.h
#include a_i2c.h>
#include a_lcd.h
#include a_key.h

0
None
xianie

5 years ago

For your info the include is





0
None
xianie

5 years ago

This is for LEDs

#include
#include
#include
#include
#include
#include

#define LED7 9
#define LED6 8
#define LED5 7
#define LED4 6
#define LED3 5
#define LED2 4
#define LED1 3
#define LED0 2

int del = 150;


void setup (void){

for (int i = 2 ; i <= 9 ; i++){
pinMode(i,OUTPUT);
}
}

void loop (void){

for(int i = 2; i <=9 ; i ++){
digitalWrite(i, HIGH);
delay(del);
digitalWrite(i,LOW);
}
for (int i = 8 ; i > 2; i --){
digitalWrite(i,HIGH);
delay(del);
digitalWrite(i,LOW);
}



}

0
None
xianie

5 years ago

I've failed to upload the program file. So i will upload the individual program here.
This is for the push button

#include
#include
#include
#include
#include

#define PB1 2
#define PB2 3
#define PB3 4

int val1 = 0;
int val2 = 0;
int val3 = 0;

void setup (void)
{
i2cInit();
lcdInitI2c(0x21);
lcdSetXY(0,0);
pinMode(PB1, INPUT_PULLUP);
pinMode(PB2, INPUT_PULLUP);
pinMode(PB3, INPUT_PULLUP);

lcdPutStr("Press Button");
}

void loop (void)
{
val1 = digitalRead(PB1);
val2 = digitalRead(PB2);
val3 = digitalRead(PB3);

if (val1 == HIGH){
lcdSetXY(0,1);
lcdPutStr("PB1 is Pressed ");
}
else if (val2 == HIGH){
lcdSetXY(0,1);
lcdPutStr("PB2 is Pressed ");
}
else if (val3 == HIGH){
lcdSetXY(0,1);
lcdPutStr("PB3 is Pressed ");
}
else {
lcdSetXY(0,1);
lcdPutStr(" ");
}
}