One of the code group is disabling the other code group


hi all

i have problem arduino codes. have 3 button 3 led , few analog inputs. button1 buton make higher ts value. button2 down buton make lower ts value. button 3 choose value want see on lcd, trr or tor values.
but when add button3's algorythm , down buttons isnt working. tried delete button3's algorythm , problem solved , down buttons changing value. when add button3's code group again  up down buttons didn't work again.
button 3 connected analog input. , calling analog inputs digital input 14-19. a0 using 14 pin number.

how can solve problem? should problem?

i hope there right place ask. , sorry bad english...

here button3's algorythm.

code: [select]

//////////////////////////faulty codes

bt3s = digitalread(bt3);

if (bt3s != lbt3s){

  if (bt3s == high){
    lcd.setcursor(0,1);
    lcd.print("        ");
    lcd.setcursor(0,1);
    lcd.print("tor:");
    lcd.setcursor(4,1);
    lcd.print(tor);
    lcd.setcursor(6,1);
    lcd.print(" ");}
   
  else{
    lcd.setcursor(0,1);
    lcd.print("trrv:");
    lcd.setcursor(5,1);
    lcd.print(trr);}
   
 lbt3s = bt3s;
///////////////////////////////faulty codes

and here codes.
---------------------------------------------------------------------------------------------------

code: [select]

#include <liquidcrystal.h>

liquidcrystal lcd(12, 11, 5, 4, 3, 2);

int rov = 0;

int tr = a0;
int trr = 0;
int = a1;
int tor = 0;
int ts = 0;
int tm = a2;
int tmr = 0;

int po = a3;
int pos = 0;

int = 7;
int buttonstate = 0;
int lastbuttonstate = 0;
int buttonstate1 = 0;
int lastbuttonstate1 = 0;
int down = 6;

int bt3 = 19;
int bt3s = 0;
int lbt3s = 0;

int led3 = 8;
int led2 = 9;
int led1 = 10;

int x1 = 40;
int x2 = 40;
int x3 = 40;
int x4 = 35;
void setup() {
 lcd.begin(16,2);
 
 pinmode(up, input);
 pinmode(down, input);
 pinmode(po, input);
 pinmode(led3, output);
 pinmode(led2, output);
 pinmode(led1, output);
 lcd.setcursor(0,0);
 lcd.print("opening");
 delay(3000);
 lcd.clear();
 lcd.setcursor(0,0);
 lcd.print("led1");
 lcd.setcursor(0,1);
 lcd.print("tor:00    tsr:00");
 
}

void loop(){
digitalwrite(led3, high);
digitalwrite(led1, high);
tor = analogread(to)/x1;
trr = analogread(tr)/x2;
tmr = analogread(tm)/x3;
lcd.setcursor(5,0);
lcd.print("on");
lcd.setcursor(14,1);
lcd.print(trr+ts);
//////////////////////////faulty codes

bt3s = digitalread(bt3);

if (bt3s != lbt3s){

  if (bt3s == high){
    lcd.setcursor(0,1);
    lcd.print("        ");
    lcd.setcursor(0,1);
    lcd.print("tor:");
    lcd.setcursor(4,1);
    lcd.print(tor);
    lcd.setcursor(6,1);
    lcd.print(" ");}
   
  else{
    lcd.setcursor(0,1);
    lcd.print("trrv:");
    lcd.setcursor(5,1);
    lcd.print(trr);}
   
 lbt3s = bt3s;
///////////////////////////////faulty codes

/////////////////////////////////////////////////value setting down buttons
      buttonstate = digitalread(up);


if (buttonstate != lastbuttonstate){
 if (buttonstate == low){
   ts++;}}
   lastbuttonstate = buttonstate;
   //////////
   buttonstate1 = digitalread(down);

   if (ts > -10){
if (buttonstate1 != lastbuttonstate1){
 if (buttonstate1 == low){
   ts--;}}
   lastbuttonstate1 = buttonstate1;
delay(10);}


//////////////////////////////////////////////////////////////////comparator algorythm
if (tor > trr+ts) {
  digitalwrite(led2, high);
  lcd.setcursor(9,0);
  lcd.print("led2on");
}
if (tor < trr+ts) {
  digitalwrite(led2, low);
  lcd.setcursor(9,0);
  lcd.print("       ");}}
 

put each } on own line. post code correctly, after read how post in forum thread.

i see nothing in first sketch ts.

i see nothing in description tells me switches wired correctly. have external pullup or pulldown resistors? if not, since not using internal pullup resistors, can forget reliably reading switch pins.


Arduino Forum > Using Arduino > Programming Questions > One of the code group is disabling the other code group


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support