Thermal printer: how to print string from an array of strings at random

Hi,

I’m new to the Arduino community, and hoping to find some kind folks to point me in the right direction.

I’m trying to code a thermal printer to print a string from an array of strings at random. The thermal printer is triggered by an IR beam breaking. I’ve run into a few problems and am not sure what to try next. I’ve attached the code and am hoping some kind person will be able to offer some pointers.

IR_Beam_Sensor_triggers_printer.ino (1.57 KB)

adaqrcode.h (11.8 KB)

adalogo.h (4.04 KB)

I've run into a few problems and am not sure what to try next.

The first thing you should try is telling us what the problems are.

The code you posted does something. You want/expect it to do something. If the two things were the same thing, you wouldn't have a reason to post (except in Exhibitions, to brag). So, I think we can conclude that what the code does is not what you want.

What it does, and what you want, though, are mysteries that you need to clear up.

I'm trying to code a thermal printer to print a string from an array of strings at random.

There are NO strings in your code.

Do you KNOW what values random(0, 2) will return? 2 will NEVER be returned.

Why do you keep appending to randString?

sensorState and lastState are NOT booleans. It does not make sense to apply boolean operations to them. There is almost certainly a better way to compare the two states, and almost certainly a better time and place to put the code that writes to the printer.

Hi there,

New to the forum, hoping a kind soul can point me in the right direction.
I’m stuck and am trying to have a thermal printer print a string from an array of strings at random. The thermal printer is triggering by the breaking of an IR beam sensor.

I’ve attached a screenshot of the code.

Thanks in advance!

(deleted)

spycatcher2k:
No - Don't post screenshots of code, post the code!

In code tags.