OLED coding

Does anyone have any idea where there is a syntax error at the start of the speech marks in every line with serout?

serout ("score: ",#score,cr,lf)(pinB.3)
serout ("overs: ",#overs,cr,lf)(pinB.3)
serout ("wickets: ",#wickets,cr,lf)(pinB.3)
if overs >= 50 then
swap b10,w0
serout ("last innings: ",cr,lf)(pinB.3)
endif
 

techElder

Well-known member
You didn't indicate that you made changes to your code. The code you listed in the first post will not work and must have given syntax error messages within the editor. You have to follow the correct syntax.

If anyone is to help with your project, you will need to also show how your hardware is wired to the PICAXE. It is one thing to choose "pinB.3", but if you don't wire your display to that hardware leg nothing will happen.

A photo would also be nice to see.
 

wayne_weedon

New Member
Alex did this simplified code work?

Code:
pause 500 'delay to allow display to settle

serout B.3,N2400,(254,128) ' move to start of first line
serout B.3,N2400,("Hello Alex!") ' output text
end
 

bfgstew

Senior Member
That is pre programmed on the OLED chip.
Follow what people have said. You have not coded correctly, read and understand the links given before you try and make alterations that maybe are not needed. What pin are you using? Show a photo of your set up, it makes life a lot easier to help you.
 
I have tried using the example code from the manual. I have been using B.3 then I switched to B.7 then I switched to B.5. I can't add a photo.
 

hippy

Technical Support
Staff member
I just have a wire going directly to the pin from the in on the OLED.
You also need to connect the OLED 0V to the PICAXE 0V.

Your serial wire also needs to connect directly to a PICAXE output pin, not through a Darlington Buffered output if your board has that.
 

lbenson

Senior Member
It won't let me add a photo. ...
What variety of "won't let you"?

There should be no problem uploading a photo of less than 1MB in size (and smaller is likely to be fine, if clear). If your snapshot is too big, you can use Paint (if on Windows) to reduce the size.
 
You also need to connect the OLED 0V to the PICAXE 0V.

Your serial wire also needs to connect directly to a PICAXE output pin, not through a Darlington Buffered output if your board has that.
So I need to connect the OLED 0V to the 0V pin or 0V rail on the PIC as well as connecting it to a separate power supply.
 
because before it wasn't working then every so often the screen would flash off and on then once it sent a very random combination of dots forming unusual characters that arent of any use.
 

bfgstew

Senior Member
That's what happens when the 0v is not connected. Follow the instructions in the manual, please.
 

hippy

Technical Support
Staff member
So I need to connect the OLED 0V to the 0V pin or 0V rail on the PIC as well as connecting it to a separate power supply.
You need to connect all the 0V connections together, and connect the serial data signal.

You don't need a separate supply for the OLED. You can connect V+ of the OLED board to the PICAXE 5V supply.

If you do connect V+ to the PICAXE 5V, do not also connect a separate OLED supply. If using a separate OLED supply do not connect the OLED V+ to PICAXE 5V. It should be one of the following -

Code:
 PICAXE                   OLED Serial Module
.------.                 .--------------------.
|   TX |-----------------| In                 |
|   5V |---.-------------| V+                 |
|   0V |---|--.----------| 0V                 |
`------'   |  |          `--------------------'
.------.   |  |
|   5V |---'  |
|   0V |------'
`------'
 PSU
Code:
 PICAXE                   OLED Serial Module
.------.                 .--------------------.
|   TX |-----------------| In                 |
|   5V |---.         .---| V+                 |
|   0V |---|--.---.--|---| 0V                 |
`------'   |  |   |  |   `--------------------'
.------.   |  |   |  |   .------.
|   5V |---'  |   |  `---| 5V   |
|   0V |------'   `------| 0V   |
`------'                 `------'
 PSU                      PSU
 
Last edited:
You need to connect all the 0V connections together, and connect the serial data signal.

You don't need a separate supply for the OLED. You can connect V+ of the OLED board to the PICAXE 5V supply.

If you do connect V+ to the PICAXE 5V, do not also connect a separate OLED supply. If using a separate OLED supply do not connect the OLED V+ to PICAXE 5V. It should be one of the following -

Code:
 PICAXE                   OLED Serial Module
.------.                 .--------------------.
|   TX |-----------------| In                 |
|   5V |---.-------------| V+                 |
|   0V |---|--.----------| 0V                 |
`------'   |  |          `--------------------'
.------.   |  |
|   5V |---'  |
|   0V |------'
`------'
 PSU
Code:
 PICAXE                   OLED Serial Module
.------.                 .--------------------.
|   TX |-----------------| In                 |
|   5V |---.         .---| V+                 |
|   0V |---|--.---.--|---| 0V                 |
`------'   |  |   |  |   `--------------------'
.------.   |  |   |  |   .------.
|   5V |---'  |   |  `---| 5V   |
|   0V |------'   `------| 0V   |
`------'                 `------'
 PSU                      PSU
Now it is just sending random characters again. Does anyone know why it would be sending random characters instead of what it is meant to send.
 

bfgstew

Senior Member
Going back to post 1, have you corrected your code so it is like post 2?
Have you connected the +v and 0v as stated?
What pin have you connected to the Ser in pin?
Answer these please.
 

bfgstew

Senior Member
So you have a 20 x 4 OLED with the 18M2 driver board.........yes?
You have another Pic that you want to control what is shown on the OLED........yes?
Is the seperate Pic wired up correctly as in the manual........?
What is the power supply?
What code are you using?
How are you telling the Pic what to display? Push button? Switch?
Are you putting the code into the sperate Pic or the onboard Pic?
Have you altered the on board Pic programme?
All we are doing at the moment is going around in circles.......until you give some definitive answers you will struggle and so will we.
 

wayne_weedon

New Member
I have been trying to help Alex also. He is trying to develop a cricket scoring system and as far as I know was using some code I reworked for him.

His initial issue in this thread was that he altered the serial terminal (sertxd) commands that I wrote for debugging purposes (I do not own a Picaxe OLED display!) incorrectly (See post #1) I then suggested he go back to basics i.e. A simple hello world style program to at least verify that serial communications to the display are at least working. Seems not to be the case.

So I think Alex needs to go right back to basics and try each feature one at a time before trying to work with the final code.

As others have said we don't know how the hardware has been configured, but if a hello world program is not working there is something fundamentally wrong with wiring or pin assignments.
 

wayne_weedon

New Member
I just quickly knocked up this code based on the code I wrote for Alex. I have taken the liberty to provide some dummy data so that the symbols in the original code were still relevant.

As i said above I do nt have an OLED Display but it ought to work?

Code:
symbol oled = b.3
symbol baud = n2400
symbol oled_cmd = 254
symbol line1 = 128
symbol line2 = 148
symbol line3 = 192
symbol line4 = 212

symbol score = 292
symbol overs = b0
overs = 51
symbol wickets = 2
symbol last_innings = 678

serout oled,baud,(oled_cmd,line1,"Score: ",#score)
serout oled,baud,(oled_cmd,line2,"Overs: ",#overs)
serout oled,baud,(oled_cmd,line3,"Wickets: ",#wickets)
if overs >= 50 then
	serout oled,baud,(oled_cmd,line4,"Last Innings: ",#last_innings)
endif

stop
 

hippy

Technical Support
Staff member
Now it is just sending random characters again. Does anyone know why it would be sending random characters instead of what it is meant to send.
There are a number of potential reasons - Commonly wrong baud rate or wrong signal polarity. Assuming everything is wired and powered correctly it could be that data is being sent before the OLED module is ready for it.

I would start with some code which is as near simple as it can get -

Code:
#Picaxe 18M2
Pause 3000
Do
  SerOut B.3, N2400, ( 254, $80 )
  SerOut B.3, N2400, ( "Count=", #w0 )
  w0 = w0 + 1
  Pause 1000
Loop
Turn it all off then on after download to ensure the OLED and PICAXE both power-on reset together.
 

Flenser

Senior Member
Alex,

You have asked questions like "Does anyone know why it would be sending random characters instead of what it is meant to send?" and "For some reason nothing is writing to the OLED. Not even the example code for serout. Any idea why this might be?"

The answers to both these questions have already been given by other people, and that answer is "it could be the hardware or it could be the software."

We can best help you if we are able to look at your hardware and software.

In order to be able to look at your hardware we would ideally get you to post a photo or a circuit diagram. You said that you are unable to upload a photo so in post #24 Hippy took the trouble to draw a couple of ways a PICAXE could be connected to an OLED but in post #27 you did not answer Hippy to say how your PICAXE and OLED are connected.

One of the reasons you could be seeing random characters would be if you hardware was not connected correctly.
How many wires do you have running from the PICAXE to the OLED?
Are there exactly three wires connected like the diagram below?

Code:
 PICAXE                   OLED Serial Module
.------.                 .--------------------.
|   TX |-----------------| In                 |
|   5V |-----------------| V+                 |
|   0V |-----------------| 0V                 |
`------'                 `--------------------'
Another reason you could be seeing random characters is if there was a problem in your code.
Looking at your code is easier. You only need to paste the code that you are running into your post. It will be more convenient for the forum to read your code if you "Go Advanced", click the code icon (which has the "#" symbol) and then paste your code in between the CODE start and & /CODE end tags that are in square backets.
 
Top