Programing with Switch Case

i'm working with "Arduino Uno" using "Switch case" that get command via Bluetooth. and it's working good, but now i want add a Photoresistor to do some automatic action if condition is present (like arduino send to him self a command to tell to do that or this if light or dark getting from the sensor ) and of course need that old command still work with bluetooth

please can someone help me with this ?

Probaby... But where is your code? And where are you stuck?

byte currentLength = 0;

void setup(){
 Serial.begin(9600);
}

void loop(){
  
if (Serial.available()){
 char input = Serial.read();
 
   switch (input){
    
    
    case 'A':
       Serial.println("78901234");
    break;

    case 'B':
       Serial.println("89012345");
    break;

   default:
      
       currentLength++;
       
       Serial.print("9");
       for (byte i=0; i<currentLength; i++){
         Serial.print('8');
       }
       Serial.println();

the problem that i want to add a sensor task with it

The program that you posted is not complete and you have not told us where you are having a problem.

my probleme i need do add photoresistor to do task if Lum=0 servo= 90 and if Lum=1024 servo = 180 and i cant find haw to do it

SMarwen:
my probleme i need do add photoresistor to do task if Lum=0 servo= 90 and if Lum=1024 servo = 180
and i cant find haw to do it

but now i want add a Photoresistor to do some automatic action if condition is present (like arduino send to him self a command to tell to do that or this if light or dark getting from the sensor ) and of course need that old command still work with bluetooth

If you want the program to respond to the photoresistor input quickly then the first thing to do is to get rid of the delay()s in your code, at least in the loop() function. Whilst the delay() is happening no other code is being executed. You need to look into using millis() for timing as in the BlinkWithoutDelay example. Save the time an event happens then each time through loop() check whether the required period has elapsed since the event. If not then go round loop() again reading inputs etc. If the period has elapsed then take the required action.

If you don't care how responsive the program is to the photoresistor input then add the code to read it and act on the input at either the start or end of the loop() function. Do you have any standalone code to do what you want or is that where you are stuck ?

yes im suck with this part of code. can you make a simple exmple haw can i do it with the code that i have send ? Please

the delay() its only for the power on then not used the arduino will stay waiting for input to do a task and with the photoresistor i want to make him do task without whaiting for input and if input come he do the task to

before adding extra code to what you already have look at the link I posted and just make a simple program that uses a LDR.

http://wiki.epalsite.com/index.php?title=Starter_Kit_for_Arduino#Lesson_11_Light_controlled_lamps

my probleme i need do add photoresistor to do task if Lum=0 servo= 90 and if Lum=1024 servo = 180 and i cant find haw to do it

I don't understand the problem. Someplace in your code add:

   if ( (lum == 0 && servo == 90) || (lum == 1024 && servo == 180) ) {
      // ...then do this code block...
   }

Do you think it's wise to have different actions for 'B' and 'b' as well as 'C' and 'c'? Seems to me that's a train wreck waiting to happen.

for the swith case no problem to use "A" and "a" as commende for deferent task

for the swith case no problem to use "A" and "a" as commende for deferent task

Oh, silly me! Users never input an 'a' when they really meant to type in an 'A'. What was I thinking?

he delay() its only for the power on then not used

except in the '?' case...