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.
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.
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.