Week01 - Interruptible LED fade

An LED fade test with Flex Sensor 4.5" taped on a A4 paper and Diffused RGB 10mm LED .

I'm trying to imitate the flare when you are using a hand fan near a candle.

Arduino code:

int FLEX_PIN = A0; 
int old = 0;
int R = 2;
int G = 3;
int B = 4;

void setup() 
  pinMode(FLEX_PIN, INPUT);
  pinMode(R, OUTPUT);
  pinMode(G, OUTPUT);
  pinMode(B, OUTPUT); 

void loop() 
  int flexADC = analogRead(FLEX_PIN);
  int inNumber = map(abs(flexADC-old),0,30,0,255);
  analogWrite(R, inNumber);
  analogWrite(G, inNumber);
  analogWrite(B, inNumber);
  old = flexADC;