so everything before void loop is fine but then i have 2 codes that im not sure how to put together. its a buzzer with and led blinking to the beat and an led controlled by a photo resister/light sensor.
Yeah the delays will probably be an issue when you join the sketches.
With the delays in the one sketch, they're not a problem as such since they don't stop anything else becasue there is nothing else. But I'm sure they will cause a problem in the combined sketch since they will stop the other stuff.
Difficult to tell though, since you only posted snippets......
The first bit of code will take 4 seconds to execute. No matter how you "combine" these 2 code, it will take 4 seconds. During that time there will be no reading of the sensorPin and no changes to the lightLevel.
You simply hae to rewrite the code. There are two major ways you can make this - as two functions (the way you have given us two fragments of your code) that have their own private variables (ie. static inside the function) OR where you replace the delay() by calls to your 2nd fragment hundredes of time with only a small delay in the 2nd piece. (the latter is messy but probably easier for you to code)
guys thanks for all of the answers but i honestly dont understand what you guys mean so could some one put the codes together as an example. thanks alot guys
yes but istill dont see how to combine the code. can i make a loop within a loop for example or say something like, light sensor always working non-stop and you loop the led and buzzer
whyisarduinosohard:
yes but istill dont see how to combine the code.
Well, that is the difference between looking for some ready to cut-n-paste code, and looking at similar examples, understand them, and then apply the principles to you code.
Abstract your thinking form your LED og and your tone() - and look for someone else that has made "two things happen at once". I could for example suggest you look for Two Leds Blinking (or words to that effect) - it is the same problem.