Pic Basic Examples

:: Programming Clues Hardware Clues General PBP examples Concepts are the intent here, rather than specifics. PICBASIC PRO program to demonstrate the steps necessary to use hardware PWM channel 3 on the 16F767 (and similar devices). PICBASIC PRO program to demonstrate 7-segment LED display. Schematic can be found at (fig 6).

PICBASIC PRO program to display result of 10-bit A/D conversion on LCD. Connect analog input to channel-0 (RA0). PICBASIC PRO program to display result of 8-bit A/D conversion on LCD. Connect analog input to channel-0 (RA0). PICBASIC PRO program to display result of 10-bit A/D conversion on LCD. Connect analog input to channel-0 (RA0).

How to build a DCF77 PIC LED CLOCK. Free Download Youtube Software For Nokia E5 more.

PICBASIC PRO program to display result of 8-bit A/D conversion on LCD. Connect analog input to channel-0 (RA0).

PICBASIC PRO program to demonstrate interrupts in assembly language. Interrupt on PORTB.0 (INTE) turns LED off. Program waits.5 seconds and turns LED back on. PICBASIC PRO program to demonstrate conversion to and from BCD. PICBASIC PRO program to to blink an LED connected to PORTB.0 about once a second PICBASIC PRO program to demonstate the BUTTON command.

Prints working variable (in this case B0) to show how auto-repeat works. Prints 'PRESS' when button is pressed or repeated. PICBASIC PRO program to demonstate the Select Case.Case. End Select structure. Each loop results in the same output using slightly different conditions. PICBASIC PRO program to demonstate the Div32 command. Div32 must be used immediately after a multiply statement in order to retain the state of the internal registers of the device.

Pic Basic Examples

PICBASIC PRO program to demonstate the EEPROM, READ and WRITE Commands. Works on targets with data EE only!!!

Initialized address 0.3 and 8. Writes 10.63. PICBASIC PRO program to demonstate the I2CREAD and I2WRITE Commands. Writes to the first 16 locations of internal I2C EEPROM, then reads first 16 locations back and send via serial out repeatedly.

Note: for PIC12CE67x MCUs. PICBASIC PRO program to demonstate the I2CREAD and I2WRITE Commands.

Writes to the first 16 locations of internal I2C EEPROM. Reads first 16 locations back and send to serial out repeatedly.

Note: for PIC16CE62x MCUs PICBASIC PRO program demonstrating how to READ and WRITE word variables to on-board EEPROM. Word is used to add 1000 to each location address and store the result. The word data must be stored as 2 separate bytes.

PICBASIC PRO program demonstrating FOR.NEXT Command. Prints series of numbers showing STEP facility. PICBASIC PRO program to demonstrate hardware PWM. Output is a 1Khz signal with duty cycle sweeping from 20% to 80% once per second.

PWM output will be on the CCP1 pin. Register names are for the PIC16F87x devices. PICBASIC PRO program to demonstrate sending and receiving with the hardware serial port. Defaults to 2400 bps. PICBASIC PRO program to demonstrate I2CREAD and I2WRITE Commands.

Writes to the first 16 locations of an external serial EEPROM, then reads first 16 locations back and sends via serial out repeatedly. For EEPROMS with byte-sized address. PICBASIC PRO program to demonstate the I2CREAD and I2WRITE commands with internal EEPROM on 12-bit core. Writes to the first 16 locations of internal I2C EEPROM, then reads first 16 locations back and send to serial out repeatedly Tested on 12CE519. Outputs: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P.

PICBASIC PRO program to demonstate the I2CREAD and I2WRITE Commands. Writes to the first 16 locations of internal I2C EEPROM. Reads first 16 locations back and send to serial out repeatedly. Note: for PIC16CE62x MCUs. PICBASIC PRO program to demonstate the I2CREAD and I2WRITE Commands. Writes to the first 16 locations of internal I2C EEPROM. Reads first 16 locations back and send to serial out repeatedly.

Note: for PIC12CE67x MCUs. PICBASIC PRO program to read and write to I2C slave. Writes a 1-byte offset value, pauses, then reads an 8 character string from the slave. Expects to find the ADC conversion value (- offset) in the 6th position of the string.

PICBASIC PRO program for I2C slave program - PIC16F877/PIC-X1. PICBASIC PRO program to demonstrate operation of an LCD in 4-bit mode. PICBASIC PRO program to display truth table for binary logical operators. PICBASIC PRO program to demonstrate the LOOKDOWN Command. Converts ASCII Hexadecimal characters to numeric equivalents. PICBASIC PRO program to demonstrate LOOKUP & RANDOM commands. Converts numeric value to ASCII hexadecimal equivalents.

PICBASIC PRO program to demonstrate MAX/MIN Operators. Uses MAX and MIN operators to Bound [0.9] to [3.7]. PICBASIC PRO program to demonstrate 1-wire temperature display with LAB-X1 and DS1820 1-wire temp sensor. PICBASIC PRO program to demonstrate use of On Interrupt Interrupts in BASIC.

Interrupt on PORTB.0 (INTE) turns LED off. Program waits.5 seconds and turns LED back on.

PICBASIC PRO program to demonstrate use of PULSIN command with Serial Pulse Width Meter. PICBASIC PRO program to demonstrate use of PULSOUT command for a variable pulse generator. Two buttons adjust from off to 10mSec in 10 uSec steps. 10/02/08 - PICBASIC PRO 2.50L test program to talk to FAT16 formatted MMC/SD cards with PIC18F4550. This is only a test program that is part of a larger project.

The complete fileset with schematic, includes, and details can be found at download: PICBASIC PRO Code that demonstrates the use of modifiers with the Serin2 and Serout2 commands. PICBASIC PRO Code that demonstrates the use of SERIN & SEROUT commands with UPPER CASE serial filter. PICBASIC PRO Code that demonstrates the use of SERIN Command with qualifiers for a 'Crude' serial filter for C Style Comments.

PICBASIC PRO Code to demonstrate the use of SHIFTIN / SHIFTOUT commands. PICBASIC PRO Code to demonstrate the SLEEP command. Slowly blinks an LED using low power mode delay. PICBASIC PRO Code to demonstrate the SOUND command. Makes random computer-like noises. More refinement might make sound effects realistic enough to convince your boss youre working when youre really just playing Doom!!! PicBasic Pro program to read and write to SPI slave using the hardware synchronous serial port.

Connect SDI(master) to SDO(slave), SDO(master) to SDI(slave), AND SCK(master) to SCK(slave). Common ground is required. Sends ascii '?' To request data, waits for a '!' To begin receiving data.

Expects to find the ADC conversion value in the 6th position of the received string. PicBasic Pro program SPI slave program (see spimast.pbp for connections) Common ground is required. PICBASIC PRO program to demonstrate reading & writing the hardware serial port without HSERIN/HSEROUT. Defaults to 2400 bps. Copyright 2015 ME Labs, Inc. 2845 Ore Mill Road, STE 4 Colorado Springs CO 80904 (719) 520-5323 (719) 520-1867 fax email.

DCF-77 PIC LED clock Did you find this site useful? Please to help www.micro-examples.com If you need a coder or a freelance programmer, DCF-77 PIC LED clock This section will show you how to build this clock: • PIC16F84 microcontroller • 4 x 7 segments LED display • Hours and minutes, or minutes and seconds are displayed, with a control button • DCF77 atomic clock, automatic time set-up and make it run on a EasyPic development circuit board. The complete schematic, and the C language source code is freely provided! What is DCF77? DCF77 is the name of a german radio station on 77.5 KHz, which gives official time and date from an atomic clock located in Francfort.

The time and date is coded into a 59 bit length frame, and is sent on the air through an antenna, by a 50 kilowatt power amplifier. A simple and tiny receiver can catch the signal, from approximately 2000 kilometers around the antenna. The pulse contained in the radio frequency signal is filtered by the receiver: a 100 ms pulse is a value of 0, a 200 ms pulse is a value of 1, there is a pulse per second, and the last second of a minute lacks (there is 2 seconds without pulse) to allow synchronisation with the next minute. There are many good web sites about DCF77, I strongly recommend to visit the official DCF77 web site: (German language) it contains all that you have to know about DCF-77.

You can also try a and select the most appropriate result for your convenience. How to build a DCF77 receiver? Chemigem Dm51 Manual High School on this page.

You don't need to build yourself a DCF77 receiver: there are ready-made, cheap modules to buy on internet, ask also your local dealer. I tried a few ones, their costs vary from 12 € to 18 €, all work very well. You will have to refer to the datasheet that comes with it, to connect it properly. They have 3 pins: • Gnd: to be grounded to the 0 V of the power supply • Pulse: output pin • Vcc: power supply, they all work fine with a +5 V power supply, please see your datasheet for limits. Some of them are using positive logic (the pulse is a rising edge from 0 volt to the voltage power supply, followed by a falling edge to 0 volt), others are using negative logic (the pulse is a falling edge from the voltage power supply to 0 volt, and a rising edge to the voltage power supply). Don't worry about this: the software of the clock handles the both of them!

You will just have to add a pull-up resistor on the pulse output in case of negative logic. The one used for this project, has been bought to my local dealer for a cost of 15 € (negative logic). My DCF77 board Once the DCF77 module in hand, you will note how fragile is it! First, You will have to mount it on a rigid circuit board, otherwise its tiny circuit board will break from the antenna quickly. This is how I managed to build my circuit board: On this picture you can see: • the vertical ferrit antenna, connected to the receiver circuit board (on the right). The ferrit stick is firmly attached to the veroboard with plastic straps • a 3 pins male connector (on the left), to plug the receiver circuit board on which a 3 pins female connector has been soldered, from left to right: Ground, signal output, Vcc.

• a vertical pull-up resistor: any value from 4.7 k to 10 k will work • a vertical chemical capacitor for decoupling the power supply: any value from 10 µF to 220 µF will work • a 4 pins male connector (see below) • a 2 x 5 pins male connector (see below) • and the receiver with its black resin to protect the circuit, with its little crystal. This is a close-up picture of the connectors: The 2 x 5 male pins will be connected to the EasyPic circuit board: it matches exactly its layout, so that an simple flat cable will allow to connect the two circuit boards. This is the pinout description of the connector: Pin number, from left to right 1 2 3 4 5 Upper line +5V bit #6 bit #4 bit #2 bit #0 Lower line Gnd bit #7 bit #5 bit #3 bit #1 Behind, we can see 4 pins: they are facing and connected to the pins 0, 2, 4, 6 of the connector, so that it is possible to choose the even io pin number of the microcontroller port, on which we want the DCF77 signal pulse to be connected. Just adjust it with the female socket, it is connected to the output of the receiver on its other extremity. This is my circuit board, ready to be connected to the EasyPic circuit board: As you can see, the output pulse of the receiver is wired to bit #4 of the microcontroller port. The ferrit stick must be perpendicular to Francfort direction, to have the best radio signal quality. Here is the receiver circuit board, connected to the EasyPic circuit board: As you can see, the receiver is connected to the PORT A of the microcontroller.

At this time, the DCF77 hardware of the project is ready! Here is the equivalent circuit schematic (): 4. EasyPic setup This section will be very short! Here is what you have to do: • put a PIC16F84A in the 18-pins socket (ensure that it will work at the speed we need) • put a 10 Mhz crystal in the socket • set to OFF all switches, except the ones who enable the 7 segments LED display • remove all pull-up jumpers • remove all extra I/O jumpers: no DS1820, no MAX232, no A/D potentiometer, etc. 5. Write the PIC It's time to write the program into the PIC! Here is the.HEX file: download it, read it in the PICFLash programmer and write it!.HEX FILE (5,47 Ko) 6. How to use it?

First, you will have to adjust the orientation of the ferrit stick, perpendicularly to the direction of Francfort, in order to have a radio signal as strong as possible. The DCF77 pulse is shown on the decimal point of the second LED display unit: when the receiver is correctly turned, the LED of the decimal point must flash regularly. Adjust the orientation if it is not good. You may also have to turn off all devices that could perturb the radio waves: TV set, cellular or wireless phones, computer and screen display, and so on, until you will get a good signal pulse. The 2 digits of the right will then increment each second: the clock is waiting for a complete DCF77 frame. Watch the video: The display has two different modes, which depend on the clock state: Clock not locked: • In this state, the clock can't display time because it has never received a complete DCF77 time frame. The clock is in this state at start time.

• The first two digits of the digits are blanked, and the two last digits show the current bit number of the frame in progress. • The decimal point of the second digit shows the pulse signal.

• The decimal point of the last digit is a correct frame indicator, it is set when no error has occured in the current frame. • If a pulse error occurs, or if a parity error is detected, the bit number is reset, the frame indicator is cleared, and a new count starts.

• If a new frame is detected, the frame indicator is set. • When a frame is completed, the bit number 59 is shown for 2 secondes, and then the clock locks, and time is displayed. Clock locked: • The pulse signal and the frame indicator act like in unlocked mode, the clock still continues to receive DCF77 frames • The first two digits show the hours, the next two ones show the minutes • While pressing the RB7 switch, the first two digits show the minutes, and the next two ones show the secondes. All decimal points are set, because the RB7 pin is used both for driving decimal points of the display, and for reading the switch. The source code You can find here the: just copy and paste it in the MikroC compiler. Adjust the initial value of the variable 'mode', depending on the kind of logic of the DCF77 receiver you have.

The program uses 861 bytes of ROM, and 62 bytes of RAM. All trademarks and registered trademarks are the property of their respective owners.