Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

Code Example: Arduino switch case

 

Switch (value): Case differentiation by this value

Case value:     if the value is true, then work out the following lines

Break:the case-block ends with break         

 

//--< calculate_buttons >--

    switch(buttons)

    {

      case BTN_PULSWIDTH_UP:

        nHighCyles=nHighCyles+1;

        break;

        

      case BTN_PULSWIDTH_DOWN:

        nHighCyles=nHighCyles-1;

        break;

    }

 

 

 

 

 

  //< read buttons TM1638 >

  uint8_t buttons = readButtons();

  //</ read buttons TM1638 >

  

  //< check buttons changed >

  bool buttons_changed=false;

  if(buttons != last_buttons) buttons_changed=true;

  //</ check buttons changed >

  last_buttons=buttons; //save buttons state

 

  if (buttons_changed && buttons>0)

  {

    Serial.println("Buttons changed to " + String(buttons));  //*value= 1 2 4 8 16 32 64 128  left to right

    

    

    //< show_button_led >

    for(uint8_t position = 0; position < 8; position++)

    {

      uint8_t mask = 0x1 << position;

      setLed(buttons & mask ? 1 : 0, position); //show Buttons on LED

    }

    //</ show_button_led >

    //--</ Read IN >--

  

    //--< calculate_buttons >--

    switch(buttons)

    {

      case BTN_PULSWIDTH_UP:

        nHighCyles=nHighCyles+1;

        break;

        

      case BTN_PULSWIDTH_DOWN:

        nHighCyles=nHighCyles-1;

        break;

    }

      

    if(nHighCyles<0) nHighCyles=0;

    //--</ calculate_buttons >--

    

    

 

    Serial.println(" nHighCycles=" + String(nHighCyles));

  }

 

Mobile
»
Switch with ESP32 MosFET and high voltages with optocoupler
»
Solved: conversion from void to non-scalar type String requested bei String.replace und toLowerCase
»
Arduino Code: Declare an Enum Type, a Variable and Compare it
»
Connect ESP32 to Bluetooth, work and write and read commands
»
Solved: LCD shows strange signs on ESP32
»
Arduino : switch case

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de