• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • About
  • Life
  • Tech
  • Travel
  • Work
  • Questions
  • Contact

Welcome

.

Thermostat seven segment

April 10, 2020 by

Questions › Thermostat seven segment
0
Vote Up
Vote Down
Garmaine asked 3 years ago

I am building a thermostat with arduino mega 2560.I would like to adjust the desired temperature and present it at two seperate seven segment displays. My problem is that it doesn't work.I think the problem is that when I call the function.I would like someone to help me with this project please. Here is my void loop code

void loop() {
  buttonStateP = digitalRead(buttonPinP);

  Wire.beginTransmission(MPU_ADDR);
  Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H) [MPU-6000 and MPU-6050 Register Map and Descriptions Revision 4.2, p.40]
  Wire.endTransmission(false); // the parameter indicates that the Arduino will send a restart. As a result, the connection is kept active.
  Wire.requestFrom(MPU_ADDR, 7*2, true); // request a total of 7*2=14 registers

  // "Wire.read()<<8 | Wire.read();" means two registers are read and stored in the same variable
  accelerometer_x = Wire.read()<<8 | Wire.read(); // reading registers: 0x3B (ACCEL_XOUT_H) and 0x3C (ACCEL_XOUT_L)
  accelerometer_y = Wire.read()<<8 | Wire.read(); // reading registers: 0x3D (ACCEL_YOUT_H) and 0x3E (ACCEL_YOUT_L)
  accelerometer_z = Wire.read()<<8 | Wire.read(); // reading registers: 0x3F (ACCEL_ZOUT_H) and 0x40 (ACCEL_ZOUT_L)
  temperature = Wire.read()<<8 | Wire.read(); // reading registers: 0x41 (TEMP_OUT_H) and 0x42 (TEMP_OUT_L)
  gyro_x = Wire.read()<<8 | Wire.read(); // reading registers: 0x43 (GYRO_XOUT_H) and 0x44 (GYRO_XOUT_L)
  gyro_y = Wire.read()<<8 | Wire.read(); // reading registers: 0x45 (GYRO_YOUT_H) and 0x46 (GYRO_YOUT_L)
  gyro_z = Wire.read()<<8 | Wire.read(); // reading registers: 0x47 (GYRO_ZOUT_H) and 0x48 (GYRO_ZOUT_L)





  // print out data
  //Serial.print("aX = "); Serial.print(convert_int16_to_str(accelerometer_x));
 // Serial.print(" | aY = "); Serial.print(convert_int16_to_str(accelerometer_y));
 // Serial.print(" | aZ = "); Serial.print(convert_int16_to_str(accelerometer_z));
  // the following equation was taken from the documentation [MPU-6000/MPU-6050 Register Map and Description, p.30]
  //Serial.print(" | tmp = "); Serial.println(temperature/340.00+36.53);
 // Serial.print(" |      |"); Serial.print(counter);
 // Serial.print(" | gX = "); Serial.print(convert_int16_to_str(gyro_x));
 // Serial.print(" | gY = "); Serial.print(convert_int16_to_str(gyro_y));
 // Serial.print(" | gZ = "); Serial.print(convert_int16_to_str(gyro_z));
 // Serial.println();
  // delay
 delay(1000);

  // compare the buttonState to its previous state
  if (buttonStateP != lastButtonStateP) {
    // if the state has changed, increment the counter
    if (buttonStateP == LOW) {
      // if the current state is HIGH then the button went from off to on:
      bPress = true;
      buttonPushCounterP++;
      if( buttonPushCounterP > 99) buttonPushCounterP =0 ;
      Serial.println("buttonPushCounterP");

    } else {
      // if the current state is LOW then the button went from on to off:
      Serial.println("off");
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
 // save the current state as the last state, for next time through the loop
  lastButtonStateP = buttonStateP;

  if( bPress ){
     turnOff();

  }


if (buttonPushCounterP = 0){

  zero1();
  zero2();
  }





dt = temperature;
 if (buttonPushCounterP < dt){
  analogWrite(ledON,1000);
}
 else if(buttonPushCounterP > dt){
  analogWrite(ledON,0);
}

}
void turnOff()
{
  digitalWrite(Aa,LOW);
  digitalWrite(Ba,LOW);
  digitalWrite(C1,LOW);
  digitalWrite(D1,LOW);
  digitalWrite(E1,LOW);
  digitalWrite(F1,LOW);
  digitalWrite(G1,LOW);

  digitalWrite(Ab,LOW);
  digitalWrite(Bb,LOW);
  digitalWrite(C2,LOW);
  digitalWrite(D2,LOW);
  digitalWrite(E2,LOW);
  digitalWrite(F2,LOW);
  digitalWrite(G2,LOW);
}```
Are you looking for the answer?
Original Question and Possible Answers can be found on `http://stackoverflow.com`

Question Tags: arduino, atmega, c++

Please login or Register to submit your answer




Primary Sidebar

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Newsletter

Complete the form below, and we'll send you all the latest news.

Footer

Footer Funnies

Who knew that reading the footer could be such a hilarious adventure? As we navigate websites, books, and documents, we often stumble upon the unassuming space at the bottom, only to discover a treasure trove of amusement. In this side-splitting compilation, we present 100 jokes that celebrate the unsung hero of content – the footer. Get ready to chuckle, giggle, and maybe even snort as we dive into the world of footnotes, disclaimers, and hidden comedic gems. Brace yourself for a wild ride through the footer!

Recent

  • Unveiling the Enigma: Almost-Magical Lamp Lights Highway Turns
  • The Impact of Young Onset Dementia on Employment and Finances: Optimizing Post-Diagnostic Approaches
  • 11 Wonders of 2023 Technological Breakthrough – Unveiling the Future
  • Work from Home and Stay Mentally Sane – Achieve Productivity and Well-being
  • Hidden Gems of New York City – Uncover the Must-See Treasures!

Search

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Copyright © 2023