Go Down

Topic: more not working on chip (Read 324 times) previous topic - next topic

secretreeve

Nov 14, 2019, 02:13 pm Last Edit: Nov 14, 2019, 02:31 pm by secretreeve
hi guys, i've reposted this here as probably a more relavant section for it to be in.

i got the code below that works fine via the arduino and a breadboard, everything does what its supposed to do, but when i load it up into an attiny45 everything works except the morse code on pin B1

ive checked the chip with another program known to work and thats fine i.e blink set to the chips pins im trying to use, tried a different one to be sure, checked the led which works and if i program it to read high it turns on by the attiny45.

i also tried the morse on another pin and nothing on that either.

so its literally the morse code aspect that doesnt work on the chip but does on a breadboard.

any ideas? (also the other state was added to see if that made a change and is removable.)

Code: [Select]
#define PIN_STATUS 1

#include <LedFlasher.h>
#include <morse.h>

LEDMorseSender sender(PIN_STATUS);
const byte WTPin = 2;
const byte CPLPin = 4;
const byte motorPin = 3;

typedef enum
  {
  initialState,
  wantCockpit,
  wantadditional,
    }
    
states;
states state = initialState;
unsigned long lastStateChange = 0;
unsigned long timeInThisState = 5;

void setup ()
  {
  pinMode (WTPin, OUTPUT);
  pinMode (CPLPin, OUTPUT);
  pinMode (motorPin, OUTPUT);
  sender.setup();
  sender.setMessage(String("h "));
  }
  
void doStateChange ()
  {
  lastStateChange = millis ();
  timeInThisState = 5;
  switch (state)
  
   {
    case initialState:
         state = wantCockpit;
         break;
        
    case wantCockpit:
         sender.startSending();
         digitalWrite (WTPin, HIGH);
         digitalWrite (motorPin, HIGH);
         state = wantadditional;
         timeInThisState = 10000;
         break;

     case wantadditional:
     timeInThisState = 1000;
     state = wantCockpit;
     break;
    }
  }
  
void loop ()
{
   if (millis () - lastStateChange >= timeInThisState)
     doStateChange ();
   if (!sender.continueSending())
 {
    sender.startSending();
  }
}





Go Up