I wanted to make a project in which there is an Ultrasonic Sensor, an OLED and a passive buzzer. I ordered those online, along with some wires and an Arduino Nano. When I had done the wiring, I opened Arduino IDE and started coding. As I had no knowledge about how an OLED display works, I searched it up on google.
After I had read a bit, I continued coding. When I plugged in my Nano in the computer, I wanted to specify the port, but it didn’t appear. There were only two ports: my bluetooth headphones and my microphone. I unplugged it and plugged it in again, the port only showing for a split second. I thought “maybe it’s the cable”, because I used an USB-Mini of another device. I went to my local electronics shop to ask for an Arduino Nano compatible wire, and I bought it.
With the new wire acquired, I plugged the Nano yet again in my computer. It was now shown, and it didn’t flicker anymore. With that problem solved, I uploaded the code to it, only showing the programmer not responding, not in sync, attempt x of 10.
sort of thing. I changed the processor directory, and it worked.
Unfortunately, nothing worked as intended: the Ultrasonic oscilated between 5 and 1023 cm, with slight changes. The OLED screen didn’t light up, not even displaying the Hello World!
I put in the void setup()
. The buzzer didn’t make a single sound, even though I coded a function that allows it to play a frequency for some defined miliseconds.
I thought “maybe the wiring is wrong”, spoiler alert, it wasn’t. So I erased the entire program and put a simple digitalWrite(an led, HIGH); delay(500); digitalWrite(the same led, LOW); delay(500);
and it worked. So I moved it to a PWM pin to see if the analogWrite()
command worked. And it did. So I did the same thing to the Ultrasonic Sensor, but the serial monitor sent random distances. The same to the OLED, it didn’t work either. So I took a button, made it INPUT_PULLUP
and checked the serial if when I pressed it the number from analogRead()
worked. It… didn’t.
Can anybody tell me what can be wrong with that? (Yes, the built-in LED lights up when I press the reset button)