Reputation: 760
I am using arduino uno to make a sound detector. I uploaded a program, found error in the code that it returns unintended numbers unreasonably big. I also think I used wrong code for the module, but it was connected in the way that can work properly with the proper code.
The code I uploaded was:
const int ledPin =13;
const int middleValue = 512;
const int numberOfSamples =128;
int sample;
long signal;
long averageReading;
long runningAverage = 0;
const int averagedOver = 16;
const int threshold=400;
void setup(){
pinMode(ledPin, OUTPUT)
Serial.begin(9600)
}
void loop(){
long sumOfSquares = 0;
for (int i=0; i<numberOfSamples; i++){
sample = analogRead(0);
signal = (sample - middleValue);
signal *= signal;
sumOfSquares += signal;
}
averageReading = sumOfSquares/numberOfSamples;
runningAverage=(((averagedOver -1 )*runningAverage)+averageReading)/averagedOver;
if(runningAverage>threshold){
digitalWrite(ledPin, HIGH);
}else{
digitalWrite(ledPin, LOW);
}
Serial.println(runningAverage);
}
When the arduino suddenly stopped sending serial numbers, I pressed reset button and uploaded the default code:
void setup() {
}
void loop() {
}
but now it shows that it cannot connect to COM3 (arduino)
and cant find the device, When I can see arduino uno
successfully connected to PC using device manager (windows 8.1)
. The led light of arduino also turns on when I connect it to power source or usb.
it shows "port not found" when I click to see the serial output
Did I just fry Arduino? How should I fix this?
Also, i checked the led pin 13 blinking three times when i plug in the usb. I just cant upload anything
Upvotes: 4
Views: 50450
Reputation: 1
To solve the problem.
Method-1: Go to Tools>Port>Select the Port
Method-2: Unplug your board and plug it back in.
Method-3: Restart your computer or laptop and reinstall Arduino software.
For more details you can visit "https://arduinopoint.com/fix-most-common-error-uploading-to-arduino/"
Upvotes: 0
Reputation: 173
You should do a few checks in order to jump to a conclusion, your Arduino may be just fine. As far as I know, Code cannot destroy a controller.
I am sure after these checks you will find out the reason of the failure of your board/microcontroller.
Upvotes: 3
Reputation: 61
What worked for me:
Tools>Port>(your COM)
Just selecting that solved the error.
Upvotes: 6
Reputation: 1
I also had a same problem and solved it. try this one. 1. disconnect all cables from your arduino 2. connect external power 3. connect usb cable 4. then upload it.
I used my arduino with CNC shield(GRBL) and plugged external power to arduino. after this. it was not possible to upload new firmware to arduino with usb cable only. Once you success to upload with usb + external power then you can upload any firmware with usb cable only.
Upvotes: 0
Reputation: 1
Yes, check everything.... especially the USB cable or the USB port. It is crucial. My problem was just dirt on the computer USB port. Dirt, dust and grime. Crazy isn't it ? Just clean up the USB port and connector and the problem solve.
Upvotes: 0