If someone could help me with the food generator part, and the Arduino actually understanding the food function, that'd be awesome
#include "FastLED.h"
#define NUM_LEDS 256
#define DATA_PIN 8
CRGB leds[NUM_LEDS];
int led = 0;
int szechuan(int);
int columns(int);
void setup() {
FastLED.addLeds<NEOPIXEL,DATA_PIN>(leds, NUM_LEDS);
pinMode(A3, INPUT);
}
void loop() {
food();
int valx = analogRead(1);
int valy = analogRead(2);
if (valx < 330) {
if ((led+1)/16 == led/16){
led++;
}
led = led % 256;
delay(200);
int morty = szechuan(led);
leds[morty] = CRGB::Green;
}
//RED
if (valx > 700) {
if ((led-1)/16 == led/16){
led--;
}
led = led % 256;
delay(200);
int morty = szechuan(led);
leds[morty] = CRGB::Green;
}
/////////////////////////
if (valy > 500) { //down
if (led + 16 <= 255){
led = led + 16;
}
led = led % 256;
delay(200);
int morty = szechuan(led);
leds[morty] = CRGB::Green;
}
if (valy < 300) { //down
if (led - 16 >= 0){
led = led - 16;
}
led = led % 256;
delay(200);
int morty = szechuan(led);
leds[morty] = CRGB::Green;
///////////////////////////////
}
FastLED.setBrightness(15);
FastLED.show();
FastLED.clear();
}
int szechuan(int n){
int output;
if ((n/16) % 2 == 1) {
output = (2 * (n/16)+1)* 16-1-n;
}
else {
output = n;
}
return output;
}
int columns(int n){
int output = (16*led)%255;
return output;
}
void food() {
int x = random(255);
leds[x] = CRGB::Red;
}