6

This line: TIMSK = (1<<OCIE1A) | (1<<TOIE1); enables a couple of interrupts generated by Timer 1. Whenever you enable an interrupt source, you should make sure that the matching ISR has been defined. Otherwise, the interrupt request is routed to __bad_interrupt(), which by default jumps to the reset vector, thus resetting your program.


3

There are multiple problems here: if(Hexa_Val[7] = 0xFF) First of all, = is the assignment operator. You are setting Hexa_Val[7] to 0xFF. If you want to compare for equality, you should use ==. Second problem, The value 0xff will never be displayed, because you are replacing it by zero. This byte will then count 0xfd, 0xfe, 0x00, skipping 0xff. If you want ...


3

We cannot know, if your python code also has a problem. But your Arduino code will send the series of "V" only once. You are using this while loop: while(counter < maxnum) in there you are incrementing the variable counter. But after you left the while loop, you are never resetting counter to zero. So the next time, counter is still equal to ...


2

I don't quite understand the code snippets, that you added to your question afterwards (they are partly incomplete). But I will propose my own solution to the problem. A melody is a list of notes and pauses. Each note has a pitch and a duration. A pause has only a duration. We can now define a struct for holding a note: struct Note { unsigned int pitch; ...


1

In essence you will need to break your for loop open and use a global variable for thisNote, incrementing it each loop (with the millis example so that proper timing is still adhered to). This isn't the only approach to this problem. Your existing code could check for the button press within the for loop and escape the for loop when pressed.


1

Note that in your case, the width of the input range (1023) is only very slightly larger than the width of the output range (1000). You could take this width difference (23) as the dead zone, and this would simplify the arithmetics: now the linear parts of your map have a slope of exactly 1, and you do not need multiplications or divisions. The map is then: ...


1

Here's how to create the new mapped range with a dead zone. I used Servo.write() which specifies the position in degrees because I couldn't understand what microsecond timings you need, but it should be easy to change it back. I've also added some debug statements to print val as the joystick is moved. #include <Servo.h> // Constants for servo angles ...


1

There's a few similar projects already done on YouTube, which you can use for guidance. If this is your 1st project using arduino I would recommend the Uno as is the easiest to work with. As you become more familiar with microcontrollers you can easily switch to the nano. As for what sensors you decide to use is up to you. You have quite a bit of flexibility....


Only top voted, non community-wiki answers of a minimum length are eligible