Go Down

Topic: Arduino Nano isn't working (Read 97 times) previous topic - next topic

ELied

Jan 13, 2018, 03:12 pm Last Edit: Jan 13, 2018, 06:05 pm by ELied
The problem begins with the Arduino Nano clone resetting itself while running the program I've uploaded, after a couple of cycle of resetting itself, it when silent with the POW LED still indicating power is still being supplied.

So I tried to hook it up to my computer with the USB and see if it would respond. My computer (Window 7) detects the device but I did not see any RX, TX or L LED light respond on the NANO, only the POW LED light. The reset button does nothing and I can't upload any code from my computer either, it would return "resp=0x44" Error.

I don't know what is wrong with the NANO, and all the search doesn't brings up anything with similar symptoms, like the NANO just gone silent~

Below is the code if you are interested in what i am doing.

Code: [Select]
#include <FastLED.h>
#include <U8glib.h>

#define LED_PIN 7
#define COLOUR_ORDER GRB
#define LED_TYPE WS2812B
#define NUM_LEDS 144
#define BRIGHTNESS 42
#define ENC_A A0
#define ENC_B A1
#define ENC_PORT PINC
#define SWT 4

#include "SoftwareSerial.h"
#include "MP3FLASH16P.h"
MP3FLASH16P myPlayer;

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);

char str[4];

int xpin = A2;
int ypin = A3;
int zpin = A6;

const unsigned long SoundTime[] = {0, 0, 0, 0, 0, 0, 2020, 635, 1718, 691, 543, 581, 508, 641, 984, 2028, 542, 581, 1231, 540};
//  const unsigned long SoundTime = 500;
int SoundTrackTracker = 0;
unsigned long previous_Sound = 0;

int swtState = 0;
int astate, alaststate, counter = constrain(counter, 0, 255);

CRGB leds[NUM_LEDS];

void setup() {
  pinMode (ENC_A, INPUT);
  digitalWrite(ENC_A, HIGH);
  pinMode (ENC_B, INPUT);
  digitalWrite(ENC_B, HIGH); 
  pinMode (SWT, INPUT);
  digitalWrite(SWT, HIGH);
  counter = 126;

  //Serial.begin(9600);

  myPlayer.init(3);
  myPlayer.setVolume(25);
  delay(3000); // power-up safety delay
  LEDS.addLeds<LED_TYPE, LED_PIN, COLOUR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(BRIGHTNESS);

  if ( u8g.getMode() == U8G_MODE_R3G3B2 )
  {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
  {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW )
  {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR )
  {
    u8g.setHiColorByRGB(255,255,255);
  }
}

void loop() {

rotaryEncoder();
OnAndOff();
SoundTrack();
ledColorChange();

u8g.firstPage(); 
  do
  {
    u8g.setFont(u8g_font_unifont);

    u8g.drawStr( 0, 12, "X Axis: ");
    u8g.drawStr( 60, 12, dtostrf(analogRead(xpin), 2, 2, str));
    u8g.drawStr( 0, 28, "Y Axis: ");
    u8g.drawStr( 60, 28, dtostrf(analogRead(ypin), 2, 2, str));
    u8g.drawStr( 0, 45, "Z Axis: ");
    u8g.drawStr( 60, 45, dtostrf(analogRead(zpin), 2, 2, str));
    u8g.drawStr( 0, 60, "Count: ");
    u8g.drawStr( 60, 60, dtostrf(counter, 2, 2, str));
  }
  while( u8g.nextPage() );
}

void OnAndOff()
{
if (digitalRead(SWT) == 0){
  if(swtState == 0){
    for(int i = 0; i < NUM_LEDS; i++){
      if(i == 0){
        myPlayer.playFile(8);
        swtState ++;
        SoundTrackTracker = 8;
      } 
    leds[i] = CHSV(counter, 187, 255);
    FastLED.show();
    }
  }
  else {
      SoundTrackTracker = 7;
      myPlayer.stopPlay();
      myPlayer.playFile(7);
      for(int a = 143; a > -1; a--){
        leds[a] = CRGB::Black;
        FastLED.show();
      if(a == 143){
        swtState --;
      }
    }
  }
}
}


void rotaryEncoder(){
 int8_t tmpdata;
 /**/
  tmpdata = read_encoder();
  if( tmpdata ) {
    counter += tmpdata;
  }
}

void SoundTrack(){
  if(digitalRead(SWT) == 1 && swtState == 1){
    unsigned long currentMillis = millis();
    int x = analogRead(xpin);
    int y = analogRead(ypin);
    int z = analogRead(zpin);
    if (y > 730 || y < 230 || x > 730 || x < 230 || z > 730 || z < 230){
        SoundTrackTracker = random(9, 11);
        myPlayer.stopPlay();
        myPlayer.playFile(SoundTrackTracker);
        previous_Sound = currentMillis;
    }
    else if (y > 600 || y < 330 || x > 600 || x < 330 || z > 600 || z < 330){
        SoundTrackTracker = random(12, 19);
        myPlayer.stopPlay();
        myPlayer.playFile(SoundTrackTracker);
        previous_Sound = currentMillis;
    }
    else if(currentMillis - previous_Sound >= SoundTime[SoundTrackTracker]){
      myPlayer.playFile(6);
      SoundTrackTracker = 6;
      previous_Sound = currentMillis;
    }
  }
}

void ledColorChange(){
  if(digitalRead(SWT) == 1 && swtState == 1){
  for(int i = 0; i < NUM_LEDS; i++){
  leds[i] = CHSV(counter, 187, 255);
  }
  FastLED.show();
  swtState = 1;
  }
}

int8_t read_encoder()
{
  static int8_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
  static uint8_t old_AB = 0;
  /**/
  old_AB <<= 2;                   //remember previous state
  old_AB |= ( ENC_PORT & 0x03 );  //add current state
  return ( enc_states[( old_AB & 0x0f )]);
}

ballscrewbob

You really really need to READ THIS POST first.

Then add the large amount of missing information.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up