#include <FastLED.h>
#define LED_PIN 3
#define COLOR_ORDER GRB
#define CHIPSET WS2811
#define NUM_LEDS 256
#define BRIGHTNESS 200
#define FRAMES_PER_SECOND 60
bool gReverseDirection = false;
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
}
void loop()
{
// Add entropy to random number generator; we use a lot of it.
// random16_add_entropy( random());
Fire2012(); // run simulation frame
FastLED.show(); // display this frame
FastLED.delay(1000 / FRAMES_PER_SECOND);
}
// Fire2012 by Mark Kriegsman, July 2012
// as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY
////
// This basic one-dimensional 'fire' simulation works roughly as follows:
// There's a underlying array of 'heat' cells, that model the temperature
// at each point along the line. Every cycle through the simulation,
// four steps are performed:
// 1) All cells cool down a little bit, losing heat to the air
// 2) The heat from each cell drifts 'up' and diffuses a little
// 3) Sometimes randomly new 'sparks' of heat are added at the bottom
// 4) The heat from each cell is rendered as a color into the leds array
// The heat-to-color mapping uses a black-body radiation approximation.
//
// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
//
// This simulation scales it self a bit depending on NUM_LEDS; it should look
// "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
//
// I recommend running this simulation at anywhere from 30-100 frames per second,
// meaning an interframe delay of about 10-35 milliseconds.
//
// Looks best on a high-density LED setup (60+ pixels/meter).
//
//
// There are two main parameters you can play with to control the look and
// feel of your fire: COOLING (used in step 1 above), and SPARKING (used
// in step 3 above).
//
// COOLING: How much does the air cool as it rises?
// Less cooling = taller flames. More cooling = shorter flames.
// Default 50, suggested range 20-100
#define COOLING 55
// SPARKING: What chance (out of 255) is there that a new spark will be lit?
// Higher chance = more roaring fire. Lower chance = more flickery fire.
// Default 120, suggested range 50-200.
#define SPARKING 120
void Fire2012()
{
// Array of temperature readings at each simulation cell
static byte heat[NUM_LEDS];
// Step 1. Cool down every cell a little
for( int i = 0; i < NUM_LEDS; i++) {
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for( int k= NUM_LEDS - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
}
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
if( random8() < SPARKING ) {
int y = random8(7);
heat[y] = qadd8( heat[y], random8(160,255) );
}
// Step 4. Map from heat cells to LED colors
for( int j = 0; j < NUM_LEDS; j++) {
CRGB color = HeatColor( heat[j]);
int pixelnumber;
if( gReverseDirection ) {
pixelnumber = (NUM_LEDS-1) - j;
} else {
pixelnumber = j;
}
leds[pixelnumber] = color;
}
}
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:GND.2
uno:RESET.2
uno:0
uno:1
uno:13
uno:3.3V
uno:AREF
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
uno:A6
uno:A7
uno:5V
uno:RESET
uno:GND.1
uno:VIN
uno:12.2
uno:5V.2
uno:13.2
uno:11.2
uno:RESET.3
uno:GND.3
p1:VDD
p1:DOUT
p1:VSS
p1:DIN
p2:VDD
p2:DOUT
p2:VSS
p2:DIN
p3:VDD
p3:DOUT
p3:VSS
p3:DIN
p4:VDD
p4:DOUT
p4:VSS
p4:DIN
p5:VDD
p5:DOUT
p5:VSS
p5:DIN
p6:VDD
p6:DOUT
p6:VSS
p6:DIN
p7:VDD
p7:DOUT
p7:VSS
p7:DIN
p8:VDD
p8:DOUT
p8:VSS
p8:DIN
p9:VDD
p9:DOUT
p9:VSS
p9:DIN
p10:VDD
p10:DOUT
p10:VSS
p10:DIN
p11:VDD
p11:DOUT
p11:VSS
p11:DIN
p12:VDD
p12:DOUT
p12:VSS
p12:DIN
p13:VDD
p13:DOUT
p13:VSS
p13:DIN
p14:VDD
p14:DOUT
p14:VSS
p14:DIN
p15:VDD
p15:DOUT
p15:VSS
p15:DIN
p16:VDD
p16:DOUT
p16:VSS
p16:DIN
p17:VDD
p17:DOUT
p17:VSS
p17:DIN
p18:VDD
p18:DOUT
p18:VSS
p18:DIN
p19:VDD
p19:DOUT
p19:VSS
p19:DIN
p20:VDD
p20:DOUT
p20:VSS
p20:DIN
p21:VDD
p21:DOUT
p21:VSS
p21:DIN
p22:VDD
p22:DOUT
p22:VSS
p22:DIN
p23:VDD
p23:DOUT
p23:VSS
p23:DIN
p24:VDD
p24:DOUT
p24:VSS
p24:DIN
p25:VDD
p25:DOUT
p25:VSS
p25:DIN
p26:VDD
p26:DOUT
p26:VSS
p26:DIN
p27:VDD
p27:DOUT
p27:VSS
p27:DIN
p28:VDD
p28:DOUT
p28:VSS
p28:DIN
p29:VDD
p29:DOUT
p29:VSS
p29:DIN
p30:VDD
p30:DOUT
p30:VSS
p30:DIN
p31:VDD
p31:DOUT
p31:VSS
p31:DIN
p32:VDD
p32:DOUT
p32:VSS
p32:DIN
p33:VDD
p33:DOUT
p33:VSS
p33:DIN
p34:VDD
p34:DOUT
p34:VSS
p34:DIN
p35:VDD
p35:DOUT
p35:VSS
p35:DIN
p36:VDD
p36:DOUT
p36:VSS
p36:DIN
p37:VDD
p37:DOUT
p37:VSS
p37:DIN
p38:VDD
p38:DOUT
p38:VSS
p38:DIN
p39:VDD
p39:DOUT
p39:VSS
p39:DIN
p40:VDD
p40:DOUT
p40:VSS
p40:DIN
p41:VDD
p41:DOUT
p41:VSS
p41:DIN
p42:VDD
p42:DOUT
p42:VSS
p42:DIN
p43:VDD
p43:DOUT
p43:VSS
p43:DIN
p44:VDD
p44:DOUT
p44:VSS
p44:DIN
p45:VDD
p45:DOUT
p45:VSS
p45:DIN
p46:VDD
p46:DOUT
p46:VSS
p46:DIN
p47:VDD
p47:DOUT
p47:VSS
p47:DIN
p48:VDD
p48:DOUT
p48:VSS
p48:DIN
p49:VDD
p49:DOUT
p49:VSS
p49:DIN
p50:VDD
p50:DOUT
p50:VSS
p50:DIN
p51:VDD
p51:DOUT
p51:VSS
p51:DIN
p52:VDD
p52:DOUT
p52:VSS
p52:DIN
p53:VDD
p53:DOUT
p53:VSS
p53:DIN
p54:VDD
p54:DOUT
p54:VSS
p54:DIN
p55:VDD
p55:DOUT
p55:VSS
p55:DIN
p56:VDD
p56:DOUT
p56:VSS
p56:DIN
p57:VDD
p57:DOUT
p57:VSS
p57:DIN
p58:VDD
p58:DOUT
p58:VSS
p58:DIN
p59:VDD
p59:DOUT
p59:VSS
p59:DIN
p60:VDD
p60:DOUT
p60:VSS
p60:DIN
p61:VDD
p61:DOUT
p61:VSS
p61:DIN
p62:VDD
p62:DOUT
p62:VSS
p62:DIN
p63:VDD
p63:DOUT
p63:VSS
p63:DIN
p64:VDD
p64:DOUT
p64:VSS
p64:DIN
p65:VDD
p65:DOUT
p65:VSS
p65:DIN
p66:VDD
p66:DOUT
p66:VSS
p66:DIN
p67:VDD
p67:DOUT
p67:VSS
p67:DIN
p68:VDD
p68:DOUT
p68:VSS
p68:DIN
p69:VDD
p69:DOUT
p69:VSS
p69:DIN
p70:VDD
p70:DOUT
p70:VSS
p70:DIN
p71:VDD
p71:DOUT
p71:VSS
p71:DIN
p72:VDD
p72:DOUT
p72:VSS
p72:DIN
p73:VDD
p73:DOUT
p73:VSS
p73:DIN
p74:VDD
p74:DOUT
p74:VSS
p74:DIN
p75:VDD
p75:DOUT
p75:VSS
p75:DIN
p76:VDD
p76:DOUT
p76:VSS
p76:DIN
p77:VDD
p77:DOUT
p77:VSS
p77:DIN
p78:VDD
p78:DOUT
p78:VSS
p78:DIN
p79:VDD
p79:DOUT
p79:VSS
p79:DIN
p80:VDD
p80:DOUT
p80:VSS
p80:DIN
p81:VDD
p81:DOUT
p81:VSS
p81:DIN
p82:VDD
p82:DOUT
p82:VSS
p82:DIN
p83:VDD
p83:DOUT
p83:VSS
p83:DIN
p84:VDD
p84:DOUT
p84:VSS
p84:DIN
p85:VDD
p85:DOUT
p85:VSS
p85:DIN
p86:VDD
p86:DOUT
p86:VSS
p86:DIN
p87:VDD
p87:DOUT
p87:VSS
p87:DIN
p88:VDD
p88:DOUT
p88:VSS
p88:DIN
p89:VDD
p89:DOUT
p89:VSS
p89:DIN
p90:VDD
p90:DOUT
p90:VSS
p90:DIN
p91:VDD
p91:DOUT
p91:VSS
p91:DIN
p92:VDD
p92:DOUT
p92:VSS
p92:DIN
p93:VDD
p93:DOUT
p93:VSS
p93:DIN
p94:VDD
p94:DOUT
p94:VSS
p94:DIN
p95:VDD
p95:DOUT
p95:VSS
p95:DIN
p96:VDD
p96:DOUT
p96:VSS
p96:DIN
p97:VDD
p97:DOUT
p97:VSS
p97:DIN
p98:VDD
p98:DOUT
p98:VSS
p98:DIN
p99:VDD
p99:DOUT
p99:VSS
p99:DIN
p100:VDD
p100:DOUT
p100:VSS
p100:DIN
p101:VDD
p101:DOUT
p101:VSS
p101:DIN
p102:VDD
p102:DOUT
p102:VSS
p102:DIN
p103:VDD
p103:DOUT
p103:VSS
p103:DIN
p104:VDD
p104:DOUT
p104:VSS
p104:DIN
p105:VDD
p105:DOUT
p105:VSS
p105:DIN
p106:VDD
p106:DOUT
p106:VSS
p106:DIN
p107:VDD
p107:DOUT
p107:VSS
p107:DIN
p108:VDD
p108:DOUT
p108:VSS
p108:DIN
p109:VDD
p109:DOUT
p109:VSS
p109:DIN
p110:VDD
p110:DOUT
p110:VSS
p110:DIN
p111:VDD
p111:DOUT
p111:VSS
p111:DIN
p112:VDD
p112:DOUT
p112:VSS
p112:DIN
p113:VDD
p113:DOUT
p113:VSS
p113:DIN
p114:VDD
p114:DOUT
p114:VSS
p114:DIN
p115:VDD
p115:DOUT
p115:VSS
p115:DIN
p116:VDD
p116:DOUT
p116:VSS
p116:DIN
p117:VDD
p117:DOUT
p117:VSS
p117:DIN
p118:VDD
p118:DOUT
p118:VSS
p118:DIN
p119:VDD
p119:DOUT
p119:VSS
p119:DIN
p120:VDD
p120:DOUT
p120:VSS
p120:DIN
p121:VDD
p121:DOUT
p121:VSS
p121:DIN
p122:VDD
p122:DOUT
p122:VSS
p122:DIN
p123:VDD
p123:DOUT
p123:VSS
p123:DIN
p124:VDD
p124:DOUT
p124:VSS
p124:DIN
p125:VDD
p125:DOUT
p125:VSS
p125:DIN
p126:VDD
p126:DOUT
p126:VSS
p126:DIN
p127:VDD
p127:DOUT
p127:VSS
p127:DIN
p128:VDD
p128:DOUT
p128:VSS
p128:DIN
p129:VDD
p129:DOUT
p129:VSS
p129:DIN
p130:VDD
p130:DOUT
p130:VSS
p130:DIN
p131:VDD
p131:DOUT
p131:VSS
p131:DIN
p132:VDD
p132:DOUT
p132:VSS
p132:DIN
p133:VDD
p133:DOUT
p133:VSS
p133:DIN
p134:VDD
p134:DOUT
p134:VSS
p134:DIN
p135:VDD
p135:DOUT
p135:VSS
p135:DIN
p136:VDD
p136:DOUT
p136:VSS
p136:DIN
p137:VDD
p137:DOUT
p137:VSS
p137:DIN
p138:VDD
p138:DOUT
p138:VSS
p138:DIN
p139:VDD
p139:DOUT
p139:VSS
p139:DIN
p140:VDD
p140:DOUT
p140:VSS
p140:DIN
p141:VDD
p141:DOUT
p141:VSS
p141:DIN
p142:VDD
p142:DOUT
p142:VSS
p142:DIN
p143:VDD
p143:DOUT
p143:VSS
p143:DIN
p144:VDD
p144:DOUT
p144:VSS
p144:DIN
p145:VDD
p145:DOUT
p145:VSS
p145:DIN
p146:VDD
p146:DOUT
p146:VSS
p146:DIN
p147:VDD
p147:DOUT
p147:VSS
p147:DIN
p148:VDD
p148:DOUT
p148:VSS
p148:DIN
p149:VDD
p149:DOUT
p149:VSS
p149:DIN
p150:VDD
p150:DOUT
p150:VSS
p150:DIN
p151:VDD
p151:DOUT
p151:VSS
p151:DIN
p152:VDD
p152:DOUT
p152:VSS
p152:DIN
p153:VDD
p153:DOUT
p153:VSS
p153:DIN
p154:VDD
p154:DOUT
p154:VSS
p154:DIN
p155:VDD
p155:DOUT
p155:VSS
p155:DIN
p156:VDD
p156:DOUT
p156:VSS
p156:DIN
p157:VDD
p157:DOUT
p157:VSS
p157:DIN
p158:VDD
p158:DOUT
p158:VSS
p158:DIN
p159:VDD
p159:DOUT
p159:VSS
p159:DIN
p160:VDD
p160:DOUT
p160:VSS
p160:DIN
p161:VDD
p161:DOUT
p161:VSS
p161:DIN
p162:VDD
p162:DOUT
p162:VSS
p162:DIN
p163:VDD
p163:DOUT
p163:VSS
p163:DIN
p164:VDD
p164:DOUT
p164:VSS
p164:DIN
p165:VDD
p165:DOUT
p165:VSS
p165:DIN
p166:VDD
p166:DOUT
p166:VSS
p166:DIN
p167:VDD
p167:DOUT
p167:VSS
p167:DIN
p168:VDD
p168:DOUT
p168:VSS
p168:DIN
p169:VDD
p169:DOUT
p169:VSS
p169:DIN
p170:VDD
p170:DOUT
p170:VSS
p170:DIN
p171:VDD
p171:DOUT
p171:VSS
p171:DIN
p172:VDD
p172:DOUT
p172:VSS
p172:DIN
p173:VDD
p173:DOUT
p173:VSS
p173:DIN
p174:VDD
p174:DOUT
p174:VSS
p174:DIN
p175:VDD
p175:DOUT
p175:VSS
p175:DIN
p176:VDD
p176:DOUT
p176:VSS
p176:DIN
p177:VDD
p177:DOUT
p177:VSS
p177:DIN
p178:VDD
p178:DOUT
p178:VSS
p178:DIN
p179:VDD
p179:DOUT
p179:VSS
p179:DIN
p180:VDD
p180:DOUT
p180:VSS
p180:DIN
p181:VDD
p181:DOUT
p181:VSS
p181:DIN
p182:VDD
p182:DOUT
p182:VSS
p182:DIN
p183:VDD
p183:DOUT
p183:VSS
p183:DIN
p184:VDD
p184:DOUT
p184:VSS
p184:DIN
p185:VDD
p185:DOUT
p185:VSS
p185:DIN
p186:VDD
p186:DOUT
p186:VSS
p186:DIN
p187:VDD
p187:DOUT
p187:VSS
p187:DIN
p188:VDD
p188:DOUT
p188:VSS
p188:DIN
p189:VDD
p189:DOUT
p189:VSS
p189:DIN
p190:VDD
p190:DOUT
p190:VSS
p190:DIN
p191:VDD
p191:DOUT
p191:VSS
p191:DIN
p192:VDD
p192:DOUT
p192:VSS
p192:DIN
p193:VDD
p193:DOUT
p193:VSS
p193:DIN
p194:VDD
p194:DOUT
p194:VSS
p194:DIN
p195:VDD
p195:DOUT
p195:VSS
p195:DIN
p196:VDD
p196:DOUT
p196:VSS
p196:DIN
p197:VDD
p197:DOUT
p197:VSS
p197:DIN
p198:VDD
p198:DOUT
p198:VSS
p198:DIN
p199:VDD
p199:DOUT
p199:VSS
p199:DIN
p200:VDD
p200:DOUT
p200:VSS
p200:DIN
p201:VDD
p201:DOUT
p201:VSS
p201:DIN
p202:VDD
p202:DOUT
p202:VSS
p202:DIN
p203:VDD
p203:DOUT
p203:VSS
p203:DIN
p204:VDD
p204:DOUT
p204:VSS
p204:DIN
p205:VDD
p205:DOUT
p205:VSS
p205:DIN
p206:VDD
p206:DOUT
p206:VSS
p206:DIN
p207:VDD
p207:DOUT
p207:VSS
p207:DIN
p208:VDD
p208:DOUT
p208:VSS
p208:DIN
p209:VDD
p209:DOUT
p209:VSS
p209:DIN
p210:VDD
p210:DOUT
p210:VSS
p210:DIN
p211:VDD
p211:DOUT
p211:VSS
p211:DIN
p212:VDD
p212:DOUT
p212:VSS
p212:DIN
p213:VDD
p213:DOUT
p213:VSS
p213:DIN
p214:VDD
p214:DOUT
p214:VSS
p214:DIN
p215:VDD
p215:DOUT
p215:VSS
p215:DIN
p216:VDD
p216:DOUT
p216:VSS
p216:DIN
p217:VDD
p217:DOUT
p217:VSS
p217:DIN
p218:VDD
p218:DOUT
p218:VSS
p218:DIN
p219:VDD
p219:DOUT
p219:VSS
p219:DIN
p220:VDD
p220:DOUT
p220:VSS
p220:DIN
p221:VDD
p221:DOUT
p221:VSS
p221:DIN
p222:VDD
p222:DOUT
p222:VSS
p222:DIN
p223:VDD
p223:DOUT
p223:VSS
p223:DIN
p224:VDD
p224:DOUT
p224:VSS
p224:DIN
p225:VDD
p225:DOUT
p225:VSS
p225:DIN
p226:VDD
p226:DOUT
p226:VSS
p226:DIN
p227:VDD
p227:DOUT
p227:VSS
p227:DIN
p228:VDD
p228:DOUT
p228:VSS
p228:DIN
p229:VDD
p229:DOUT
p229:VSS
p229:DIN
p230:VDD
p230:DOUT
p230:VSS
p230:DIN
p231:VDD
p231:DOUT
p231:VSS
p231:DIN
p232:VDD
p232:DOUT
p232:VSS
p232:DIN
p233:VDD
p233:DOUT
p233:VSS
p233:DIN
p234:VDD
p234:DOUT
p234:VSS
p234:DIN
p235:VDD
p235:DOUT
p235:VSS
p235:DIN
p236:VDD
p236:DOUT
p236:VSS
p236:DIN
p237:VDD
p237:DOUT
p237:VSS
p237:DIN
p238:VDD
p238:DOUT
p238:VSS
p238:DIN
p239:VDD
p239:DOUT
p239:VSS
p239:DIN
p240:VDD
p240:DOUT
p240:VSS
p240:DIN
p241:VDD
p241:DOUT
p241:VSS
p241:DIN
p242:VDD
p242:DOUT
p242:VSS
p242:DIN
p243:VDD
p243:DOUT
p243:VSS
p243:DIN
p244:VDD
p244:DOUT
p244:VSS
p244:DIN
p245:VDD
p245:DOUT
p245:VSS
p245:DIN
p246:VDD
p246:DOUT
p246:VSS
p246:DIN
p247:VDD
p247:DOUT
p247:VSS
p247:DIN
p248:VDD
p248:DOUT
p248:VSS
p248:DIN
p249:VDD
p249:DOUT
p249:VSS
p249:DIN
p250:VDD
p250:DOUT
p250:VSS
p250:DIN
p251:VDD
p251:DOUT
p251:VSS
p251:DIN
p252:VDD
p252:DOUT
p252:VSS
p252:DIN
p253:VDD
p253:DOUT
p253:VSS
p253:DIN
p254:VDD
p254:DOUT
p254:VSS
p254:DIN
p255:VDD
p255:DOUT
p255:VSS
p255:DIN
p256:VDD
p256:DOUT
p256:VSS
p256:DIN