c++ - MSP430 + Energia LED lighting based off ambient sound multiple functions -
i'm working on personal side project fun. don't have arduino have msp430g2553 i'm having fun with. pretty new coding don't murder me. project, trying write program 3 functions. have first working, non-addressable rgb strip turning off , on based on ambient sound lm393 sound detector. second, i'd respond ambient light in room. however, not sure how separate code. when function runs turns on led's, turn them off setting them low. however, program continuously runs through loop turning them on. how fix this? separate function? when attempting light sensor working runs through sound detector code resulting in issues.
so did first function working because wanted have led's change colors based on analog value given serial monitor. however, values of statussensor not change led's correctly. if give me pointer i'd grateful, isn't main question, don't have answer or have answer first question, insight beyond ever ask if guys.
here code working on - - - using energia run everything
thanks!
edit
turning sensors off , on physical toggle switches.
edit
i think figured out. state change detection via push buttons or current switches. learning ..
int redled = 3; int greenled = 5; int blueled = 6; int soundsensor = 7; void setup() { pinmode (soundsensor, input); pinmode (redled, output); pinmode (greenled, output); pinmode (blueled, output); digitalwrite (redled, low); digitalwrite (greenled, low); digitalwrite (blueled, low); } void loop() { int statussensor = digitalread (soundsensor); if (statussensor == 1) { digitalwrite(redled, low); digitalwrite(greenled, low); digitalwrite(blueled, low); } else { digitalwrite(redled, high); digitalwrite(greenled, high); digitalwrite(blueled, high); } }
Comments
Post a Comment