Start a new topic

need some help

i have a couple codes that i'm getting errors on. I do not know how to change them to get them to compile and i need to have this finished today.



#include <OneWire.h>

#include "Nextion.h"

 


int heat = 22; //heat plugged into digital 22

int ac = 32; //ac plugged into digital 32

int partitionUp = 13; //PWM

int partitionDown = 12;

 

 

OneWire ds(10); // on pin 10 (a 4.7K resistor is necessary)

 

NexNumber tempvalue = NexNumber(2, 5, "tempvalue"); 

NexButton add = NexButton(2, 3, "add");

NexButton minus = NexButton(2, 4, "minus");

NexButton pup = NexButton(3, 2, "pup");

NexButton pdown = NexButton(3, 3, "pdown");

char buffer[100] = {0};

 

void tempvaluePopCallback(void *ptr); 

void addPopCallback(void *ptr);

void minusPopCallback(void *ptr);

void pupPushCallback(void *ptr);

void pdownPushCallback(void *ptr);

NexTouch *nex_Listen_List[] =

{

  &pup,

  &pdown,

  &add,

  &minus,

  &tempvalue,

  NULL

};

 

void pupPushCallback(void *ptr)

{

  digitalWrite(partitionUp, HIGH);

}

 

void pdownPushCallback(void *ptr)

{

  digitalWrite(partitionDown, HIGH);

}

void tempvaluePopCallback(void *ptr)

{

  bool getValue(uint32_t *number);

  dbSerialPrintln("tempvaluePopCallback");

}

void addPopCallback(void *ptr)

{

  uint32_t number;

  dbSerialPrintln("addPopCallback");

  tempvalue.getValue(&number);

  number += 1;

  tempvalue.setValue(number);

}

 

void minusPopCallback(void *ptr)

{

  uint32_t number;

  dbSerialPrintln("minusPopCallback");

  tempvalue.getValue(&number);

  number -= 1;

  tempvalue.setValue(number);

}

 

void setup() /****** SETUP: RUNS ONCE ******/

{

nexInit();

  tempvalue.attachPop(tempvaluePopCallback);

  add.attachPop(addPopCallback);

  minus.attachPop(minusPopCallback);

  pup.attachPush(pupPushCallback);

  pdown.attachPush(pdownPushCallback);

  dbSerialPrintln("Setup done");

Serial.begin(9600);

  pinMode(heat, OUTPUT);

  pinMode(ac, OUTPUT);

  pinMode(partitionUp, OUTPUT);

  pinMode(partitionDown, OUTPUT);

 

}//--(end setup )---

 

 

void loop() /****** LOOP: RUNS CONSTANTLY ******/

{

nexLoop(nex_Listen_List);

byte i;

  byte present = 0;

  byte type_s;

  byte data[12];

  byte addr[8];

  float celsius, fahrenheit;

 

  if ( !ds.search(addr)) {

    ds.reset_search();

    delay(250);

    return;

  }

 

  if (OneWire::crc8(addr, 7) != addr[7]) {

      return;

  }

 

 

  // the first ROM byte indicates which chip

  switch (addr[0]) {

    case 0x10:

      type_s = 1;

      break;

    case 0x28:

      type_s = 0;

      break;

    case 0x22:

      type_s = 0;

      break;

    default:

      return;

  }

 

  ds.reset();

  ds.select(addr);

  ds.write(0x44, 1); // start conversion, with parasite power on at the end

 

  delay(1000); // maybe 750ms is enough, maybe not

  // we might do a ds.depower() here, but the reset will take care of it.

 

  present = ds.reset();

  ds.select(addr);

  ds.write(0xBE); // Read Scratchpad

  Serial.print(" ");

  for ( i = 0; i < 9; i++) { // we need 9 bytes

    data[i] = ds.read();

  }

  // Convert the data to actual temperature

  // because the result is a 16 bit signed integer, it should

  // be stored to an "int16_t" type, which is always 16 bits

  // even when compiled on a 32 bit processor.

  int16_t raw = (data[1] << 8) | data[0];

  if (type_s) {

    raw = raw << 3; // 9 bit resolution default

    if (data[7] == 0x10) {

      // "count remain" gives full 12 bit resolution

      raw = (raw & 0xFFF0) + 12 - data[6];

    }

  } else {

    byte cfg = (data[4] & 0x60);

    // at lower res, the low bits are undefined, so let's zero them

    if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms

    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms

    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms

    //// default is 12 bit resolution, 750 ms conversion time

  }

  celsius = (float)raw / 16.0;

  fahrenheit = celsius * 1.8 + 32.0;

 

  Serial.print(fahrenheit);

  Serial.println("Fahrenheit");

   if ("fahrenheit" < tempvalue)

  {

    digitalWrite(heat, HIGH);

  }

   else

  {

    digitalWrite(heat, LOW);

  }

 

  if("fahrenheit" > tempvalue)

  {

    digitalWrite(ac,HIGH);

  }

    else

  {

  digitalWrite(ac,LOW);

  }

 

}//--(end main loop )---

 

/*-----( Declare User-written Functions )-----*/

 

 

//*********( THE END )***********



and 


#include <Nextion.h>

#include <SoftwareSerial.h>

const int bar = 8;

 

// variables will change:

int brightness = 0;

SoftwareSerial mynextion(10,11);

 

void setup() {

  pinMode(bar, OUTPUT);

  Serial.begin(9600);

}

 

void loop()

{

   mynextion.listen();

   if(listen() == "65 4 8 0 ffff ffff ffff") brightness++;

   if(brightness > 255) brightness = 255;

   if(listen() == "0x65 0x04 0x09 0x00 0xff 0xff 0xff") brightness--;

   if(brightness < 0) brightness = 0;

   analogWrite(8, brightness);

   delay(10)

}


Login or Signup to post a comment