Hot answers tagged

4

Your breadboard is one of those which have the power/GND lines interrupted between columns 31 and 33. I also once fell into this trap. If you look closely, you see that the blue and red lines are interrupted in the middle of the board. Just put wires between these pins to bridge the gap.


3

It's working as intened. The arduino UNO has no DAC (digital to analog converter) onboard, so all it can produce are digital signals, either 0 or 5v. The analogWrite function uses Pulse Width Modulation to produce an output that, on average, has the requested voltage, by quickly alternating between logic low and high with different durations. This is done at ...


3

There's two problems here. First, you don't enter "234", you enter "2" followed by "3" and finally "4". Your really small timeout doesn't give the digits enough time to arrive. Second, your line ending is being received and interpreted as "not a number" which is returned as 0 by .toInt(). What you need to do ...


3

There are a couple of issues here. One of them has already been raised in a comment: int main() { - ddrB = (port_type) 0x20; + *ddrB = (int8_t) 0x20; while(true) { The more serious issue is in the command line you used to compile the program. When compiling for an Uno, you should add the option -mmcu=atmega328p. This way the compiler ...


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

The C library function atoi() will do that for you


1

timestamp in rtcReadTime() is a local variable. When you return from that function it ceases to exist - so what you have returned is nothing. You can't print nothing, so the Arduino crashes. You either need to make the timestamp variable static so that it's not lost when you leave the function, make it a global variable, which has a similar effect, or pass a ...


1

You are wrongly using the new operator for your arrays. That will dynamically allocate these arrays. They are put on the heap (not the stack like local variables) and thus don't get freed automatically, when the function exits. That has to be done by your code with the delete keyword. Your code just eats up all the available memory. Thats called a memory ...


1

You check StickMan and Object only X position not check Y position incase you can check StickMan Y or check StickMan action like this code below. or try this sim https://www.tinkercad.com/things/1LiyoY5n1mS-copy-of-stickman-rush/editel?sharecode=X6rMj1GjrKoAH95qWKY21z98ttyAs5aOTAKYy6hVJ3c // Defind it on top bool stickManIsJump = false; // Added some code ...


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.


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