Hi, I’m currently working on a POV Globe powered by an Arduino Nano and 39 APA102 RGB LED’s. The physical build is done, but I have some problems to program the LED’s. I’m using the FastLED library (open for any other library recommendations) and I try to light up some letters on my globe. I’ve found some example code (from GreatScott) but it isn’t working on me even if I just copy the code (not copying it in final project, just a guideline). I think the reason why the code isn’t working are those code lines which i have no clue about what they do…so if someone could explain it to me I’be happy. I think it has something to do with the hall effect sensor he is using, I’m also using one but it is from an older project and is High when no magnet is near to him, the signal gets Low when the magnet is near to him. I have to use an analog input to read the state of the sensor because the high signal of it isn’t 5V, instead it is 4V which isn’t enough that the Nano is recognizeing it as High(actually it should do it but it won’t). This method worked for me in other projects with the hall sensor as well. So if someone could explain to me these lines and tell me how to change it if it has something to do with the hall effect sensor I’d be happy!
The hole .ino file is attached. For better understanding my misunderstanding is about these lines:
EICRA = 0;
EICRA |= (1 << ISC10);
EIMSK = 0;
EIMSK |= (1 << INT1);
sei();
ISR (INT1_vect) {
hall = 1;
}
This is all ot the code:
#include "FastLED.h"
#define NUM_LEDS 38
#define DATA_PIN 11
#define CLOCK_PIN 13
unsigned char i;
unsigned char m;
unsigned int wait = 50;
unsigned int wait2 = 500;
bool hall = 0;
CRGB leds[NUM_LEDS];
bool G[8][5] = {
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 1, 1, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 1, 1, 1, 1}
};
bool R[8][5] = {
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 1, 1, 1, 1},
{1, 1, 0, 0, 0},
{1, 0, 1, 0, 0},
{1, 0, 0, 1, 0},
{1, 0, 0, 0, 1},
};
bool A[8][5] = {
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
};
bool T[8][5] = {
{1, 1, 1, 1, 1},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 1, 0, 0},
};
bool S[8][5] = {
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 1, 1, 1, 1},
{0, 0, 0, 0, 1},
{0, 0, 0, 0, 1},
{0, 0, 0, 0, 1},
{1, 1, 1, 1, 1},
};
bool C[8][5] = {
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 1, 1, 1, 1},
};
bool H[8][5] = {
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 1, 1, 1, 1},
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1}
};
bool E[8][5] = {
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 1, 1, 1, 1},
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 1, 1, 1, 1}
};
bool L[8][5] = {
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 1, 1, 1, 1}
};
bool O[8][5] = {
{1, 1, 1, 1, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 1, 1, 1, 1}
};
void setup() {
FastLED.addLeds<APA102, BGR>(leds, NUM_LEDS);
EICRA = 0;
EICRA |= (1 << ISC10);
EIMSK = 0;
EIMSK |= (1 << INT1);
sei();
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
}
ISR (INT1_vect) {
hall = 1;
}
void loop() {
if (hall == 1) {
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (G[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (R[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (E[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (A[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (T[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (S[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (C[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (O[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (T[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (m = 0; m < 5; m++) {
for (i = 0; i < 8; i++) {
if (T[i][m] == 1) {
leds[i + 11] = CRGB::Red;
}
else {
leds[i + 11] = CRGB::Black;
}
}
FastLED.show();
delayMicroseconds(wait);
}
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
for (int i = 11; i < 17; i++) {
leds[i] = CRGB ::Red;
}
leds[18] = CRGB::Red;
FastLED.show();
delayMicroseconds(wait);
for (int i = 0; i < 38; i++) {
leds[i] = CRGB ::Black;
}
FastLED.show();
delayMicroseconds(wait2);
hall = 0;
}
}