Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15825

Help with conditions

$
0
0

Hello,
I'm trying to use some conditions based in an integer value (from a touch screen). Though I have the values changed at my serial monitor I cannot find the proper way ti implement them to my code (not enough knowledge I guess). I tried if, while, do...while statements without success. Any help will be appreciated.


```cpp
int gests = 0;
int gestureData = 0;
float temp = 0;
float hum = 0;


void setup() {
  Serial.begin(115200);
  I2C_16Bit_begin();
#ifdef GFX_EXTRA_PRE_INIT
  GFX_EXTRA_PRE_INIT();
#endif
  gfx->begin();
  gfx->setTextColor(WHITE, BLACK);
  gfx->setTextSize(4);
  gfx->fillScreen(BLACK);

  gfx->draw16bitRGBBitmap(35, 60, (const uint16_t *)TEMP, 28 /*IMG_WIDTH*/, 47 /*IMG_HEIGHT*/);
  gfx->draw16bitRGBBitmap(35, 120, (const uint16_t *)HUM, 32 /*IMG_WIDTH*/, 47 /*IMG_HEIGHT*/);
  gfx->drawRoundRect(90, 200, 60, 30, 25, WHITE);
  gfx->drawRoundRect(88, 198, 64, 34, 25, WHITE);
}


void loop() {
  uint16_t registerData = I2C_16Bit_readFromModule(I2C_ADDR, DATA_REGISTER_ADDR);
  gests = registerData / 100;


  temp = analogRead(A0) / 8.2;
  gfx->setCursor(80, 70);
  gfx->println(temp);

  hum = analogRead(A2) / 3.9;
  gfx->setCursor(80, 130);
  gfx->println(hum);
  gfx->fillCircle(105, 215, 12, BLUE);
  gfx->fillCircle(135, 215, 12, RED);
  // do { gfx->fillCircle(135, 215, 12, BLACK); } while (gestureData == 12);
  // do { gfx->fillCircle(105, 215, 12, BLACK); } while (gestureData == 30);
  while (gestureData == 12) { gfx->fillCircle(135, 215, 12, BLACK); }
  while (gestureData == 30) { gfx->fillCircle(105, 215, 12, BLACK); }
  Serial.println(gests);
  delay(900);
}

Lucas

24 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 15825

Latest Images

Trending Articles



Latest Images