Pic Lab. PIC18. Experiment #6. Touch sensor using ADC

Task: To study the possibility of using of the DIY touch capacitive sensor on the pcb

Tools: PIC18f1230, a pcb with exposed square copper areas

So long story short, my cheap amazon lamp did not survive for a long time, but I really did like the LED light it gave. In the article below I will describe how to use a copper pad and the pic microcontroller without much additional circuitry.

Touch sensor touched and untouched

Continue reading

Pic Lab, PIC18, Experiment #1.1, UART / USART (updated version)

Recently, I was constantly struggling with the fact that microchip was removing more and more support libraries, so it was not wise to rely on them in all projects. Anytime I return again to my old functions – if it used the support libs, there is a pretty good chance it is screwed.

So this code works with XC8 version 2.36 and doesn’t require the involvement of extra support lib.

Continue reading

Pic Lab, PIC18, Experiment #3, ADC

I was working on a small project where I needed to catch a certain button pressed event. Sounds simple initially, but I have 10 such buttons and it means that I need to have 10 IOs, or port expander, or make a digital matrix button handler (like 3×4 keypad) but these all variants are boring, I wanted something more interesting and make something like a DAC based on these buttons which will be digitazed by the built-in ADC in pic18f14k50. Thus, we will use a single port instead of 10, by cost of the more complicated code.

Let me start as usual – from reading of the datasheet.

Continue reading

Pic Lab, PIC18, Experiment #1, UART in PIC18

This was a time to switch to XC8 compiler, it was not hard at all, but appeared that using of UART in PIC18 series has some peculiarities.

At the moment of this article the XC8 compiler had libraries for work with a periphery in the folder /includes/plib. Now they got rid of it and experimenting with a different approach. Anyway the legacy support looks like quite a strong side for microchip. Well I used then usart.h library which now I regret I did.

Out tasks are:

  • To write a single symbol
  • To write a string
  • To read 1 symbol = 1 byte
  • To read a couple of bytes

I will be working with PIC18F14K50.

Continue reading