how do I get my .ino to get this variable from the .h ?
(+ any tips for the project in general? I want to eventually use an API to fetch a random number, which will select 1 of 100 img files from the sd card, and print it using a thermal printer)
"Compilation error: 'chosenFileData' was not declared in this scope"
ino:
#include "Adafruit_Thermal.h"
#include "adalogo.h"
#include "adaqrcode.h"
#include "printerHFile.h"
// Here's the new syntax when using SoftwareSerial (e.g. Arduino Uno) ----
// If using hardware serial instead, comment out or remove these lines:
#include "SoftwareSerial.h"
#define TX_PIN 6 // Arduino transmit YELLOW WIRE labeled RX on printer
#define RX_PIN 5 // Arduino receive GREEN WIRE labeled TX on printer
SoftwareSerial mySerial(RX_PIN, TX_PIN); // Declare SoftwareSerial obj first
Adafruit_Thermal printer(&mySerial); // Pass addr to printer constructor
// Then see setup() function regarding serial & printer begin() calls.
// Here's the syntax for hardware serial (e.g. Arduino Due) --------------
// Un-comment the following line if using hardware serial:
//Adafruit_Thermal printer(&Serial1); // Or Serial2, Serial3, etc.
// -----------------------------------------------------------------------
////////////// SD CARD READING INITIALISATION ////////////////////////
#include <SD.h>
const int chipSelect = 10;
File myFile;
///////////m e:
char chosenFileData;
//////////////////////////////////////////////////////////////////////
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
// wait for Serial Monitor to connect. Needed for native USB port boards only:
while (!Serial);
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed. Things to check:");
Serial.println("1. is a card inserted?");
Serial.println("2. is your wiring correct?");
Serial.println("3. did you change the chipSelect pin to match your shield or module?");
Serial.println("Note: press reset button on the board and reopen this Serial Monitor after fixing your issue!");
while (true);
}
Serial.println("initialization done.");
///
//open the file for reading:
myFile = SD.open("'j1', 384x533px.txt");
if (myFile) {
Serial.println("'j1', 384x533px.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
// Serial.write(myFile.read());
char chosenFileData = myFile.read ;
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening 'j1', 384x533px.txt");
}
////////// PRINTER SETUP //////////////////////////////////
// This line is for compatibility with the Adafruit IotP project pack,
// which uses pin 7 as a spare grounding point. You only need this if
// wired up the same way (w/3-pin header into pins 5/6/7):
pinMode(7, OUTPUT); digitalWrite(7, LOW);
// NOTE: SOME PRINTERS NEED 9600 BAUD instead of 19200, check test page.
mySerial.begin(19200); // Initialize SoftwareSerial
//Serial1.begin(19200); // Use this instead if using hardware serial
printer.begin(); // Init printer (same regardless of serial type)
////// <<< deleted some examples on text printing >.> /////////////
// Print the 75x75 pixel logo in adalogo.h:
printer.printBitmap(adalogo_width, adalogo_height, adalogo_data);
printer.printBitmap(printerHFile_width,printerHFile_height,printerHFile_data);
// // Print the 135x135 pixel QR code in adaqrcode.h:
// printer.printBitmap(adaqrcode_width, adaqrcode_height, adaqrcode_data);
// printer.println(F("Adafruit!"));
printer.feed(2);
printer.sleep(); // Tell printer to sleep
delay(3000L); // Sleep for 3 seconds
printer.wake(); // MUST wake() before printing again, even if reset
printer.setDefault(); // Restore printer to defaults
}
void loop() {
}
printerHFile.h
#define j1scaled_width 384
#define j1scaled_height 533
static const uint8_t PROGMEM jprinterHFile_data [] = {
chosenFileData ;
};
arduino uno r4 wifi