rhd
0
- Joined
- Dec 7, 2010
- Messages
- 8,469
- Points
- 0
Sorry for not jumping in sooner. Life has been crazy here.
I know you deleted the posts but I remember the gist of them from my email notifications. You won't be able to use any Hex programmer, or any physical flashing device that requires a hex programmer or IDE (program used to program things in). The Atmel family chips (ATTiny, ATMega, etc) all require a specific type of IDE, and it turns out that the Arduino IDE is simply the most user friendly and basic program to do this in, especially since it is free, widespread, and has a HUGE support base.
I'll read up on your other thread and see if there's any more pertinent info you've let out.
I can certainly walk you through the process I use for flashing these chips, but you'll need a Arduino of some kind (I'd grab a UNO if I were you, but clones work just as well as long as they're functional).
Alright, so the good news is that the higher quality AVR programmer I ordered works great, and I've been flashing code revisions onto an ATTINY85 over and over again with absolutely no issues.
The bad news, is that our code doesn't work
The code, as it stood in Sig's post here, simply lit up all 3 channels, and then wouldn't respond to buttons.
1) I debugged first by putting some code right after the button press that blinked all three channels, and was able to identify that the button press was working. However, it never actually changed channel combinations, they always ended up lit up.
2) I removed the randomness code, and the EEPROM reading, and arbitrarily set the first color choice in hard code, and removed option 8 (random) entirely. I also increased trigger count from 10 to 25 and introduced a 10 ms delay after each increment. Now the paired down code works. I can move through modes 1 through 7. But I had to pull out the randomness code to do it Here's what the butchered (but working) code looks like:
Code:
// RHD's TTL Color Selector
// Programming by Matt "Sigurthr" Giordano 08/18/2014
// Website: www.SigurthrEnterprises.com
// Email: Sigurthr@SigurthrEnterprises.com
// and by Things of LaserPointerForums.com 08/15/2014
// ATTiny85 Physical Pinout - innermost designation is code addressable
// _______
// Reset _| |_| |_ Vcc
// ADC3 Pin3 3 _| |_ 2 Pin2 ADC1
// ADC2 Pin4 A2 _| ATT85 |_ 1 Pin1 Digital-1
// Gnd _| |_ 0 Pin0 Digital-0
// |_______|
#include <EEPROM.h> // include the EEPROM Memory library
boolean pinOptions[7][3] = { // Array of pin combinations (1 = on, 0 = off)
{1,1,1},
{1,0,0},
{1,1,0},
{0,1,0},
{0,1,1},
{0,0,1},
{1,0,1}
};
byte PressDetects = 0;
byte ButtonPin = 3; // see pinout
byte ColorOnePin = 0; // see pinout
byte ColorTwoPin = 1; // see pinout
byte ColorThreePin = 2; // see pinout
byte MemVar;
byte ButtonPinState;
byte ColorChoice;
byte MemoryLocation = 1;
byte TriggerCount = 25; // threshold for debounce
void setup (){ // this subroutine runs once upon startup
// Choosing 3 arbitrarily
MemVar = 0;
pinMode (0, OUTPUT); // set pin 0 to output
pinMode (1, OUTPUT); // set pin 1 to output
pinMode (2, OUTPUT); // set pin 2 to output
pinMode (3, INPUT); // set pin 3 to input
}
void loop(){ // this subroutine runs continuously after setup finishes
ButtonPinState = digitalRead(ButtonPin); // read ButtonPin to ButtonPinState
if (ButtonPinState == HIGH){ // when ButtonPinState is HIGH...
++ PressDetects; // increment detection variable
delay(10);
}
if (PressDetects >= TriggerCount) { // when threshold is exceeded...
++ MemVar; // increment memory variable
PressDetects = 0; // reset button detector
if (MemVar >= 8){ // on 8th button press...
MemVar = 1; // reset color
}
}
ColorChoice = MemVar;
digitalWrite(ColorOnePin, pinOptions[ColorChoice-1][0]);
digitalWrite(ColorTwoPin, pinOptions[ColorChoice-1][1]);
digitalWrite(ColorThreePin, pinOptions[ColorChoice-1][2]);
}
Last edited: