Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

Sort By

USER REQUESTS

first | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 last
david aspinall
lightinguk

posted on 2013/02/06 03:08:42 AM CET

Measurement

ulrasonic hc-sr04

Hi
The code below dose work but dose not calculate the distance propply
can some kind person tell me what i am doing wrong


program MyPortB
#DEFINE OSC 20
' pic16f877
dim LCD_RS as sbit at RD2_bit
LCD_EN as sbit at RD3_bit
LCD_D4 as sbit at RD4_bit
LCD_D5 as sbit at RD5_bit
LCD_D6 as sbit at RD6_bit
LCD_D7 as sbit at RD7_bit

dim LCD_RS_Direction as sbit at TRISD2_bit
LCD_EN_Direction as sbit at TRISD3_bit
LCD_D4_Direction as sbit at TRISD4_bit
LCD_D5_Direction as sbit at TRISD5_bit
LCD_D6_Direction as sbit at TRISD6_bit
LCD_D7_Direction as sbit at TRISD7_bit

dim Triger as sbit at portb.2
dim ch as string[8]
dim number as word


main:
trisa=0
Trisb =0 ' designate portb as output (LCD is connected to portb)
trisc=0
portb=0
trisd=0
portd=0
trisb.4 =1
trisb.2=0


Lcd_Init() ' initialize (4-bit interface connection)
Lcd_Cmd(_LCD_CURSOR_OFF) ' send command to LCD (cursor off)
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1,"Number")
number=00

while true '

Ow_Reset(PORTB, 4)
Triger =true '1 ' portb.2 =1
delay_us(50)
Triger =false ' 0 ' portb.2=0
number = Ow_Read(PORTB, 4)
number = number + (Ow_Read(PORTB, 4) << 8)

number = (number /2)/ 29.1

wordToStr(number, ch)
Lcd_Out(2,8,ch)
delay_us(500)
wend
' Main program
end.

david aspinall
lightinguk

posted on 2013/02/06 03:08:35 AM CET

Measurement

ulrasonic hc-sr04

Hi
The code below dose work but dose not calculate the distance propply
can some kind person tell me what i am doing wrong


program MyPortB
#DEFINE OSC 20
' pic16f877
dim LCD_RS as sbit at RD2_bit
LCD_EN as sbit at RD3_bit
LCD_D4 as sbit at RD4_bit
LCD_D5 as sbit at RD5_bit
LCD_D6 as sbit at RD6_bit
LCD_D7 as sbit at RD7_bit

dim LCD_RS_Direction as sbit at TRISD2_bit
LCD_EN_Direction as sbit at TRISD3_bit
LCD_D4_Direction as sbit at TRISD4_bit
LCD_D5_Direction as sbit at TRISD5_bit
LCD_D6_Direction as sbit at TRISD6_bit
LCD_D7_Direction as sbit at TRISD7_bit

dim Triger as sbit at portb.2
dim ch as string[8]
dim number as word


main:
trisa=0
Trisb =0 ' designate portb as output (LCD is connected to portb)
trisc=0
portb=0
trisd=0
portd=0
trisb.4 =1
trisb.2=0


Lcd_Init() ' initialize (4-bit interface connection)
Lcd_Cmd(_LCD_CURSOR_OFF) ' send command to LCD (cursor off)
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1,"Number")
number=00

while true '

Ow_Reset(PORTB, 4)
Triger =true '1 ' portb.2 =1
delay_us(50)
Triger =false ' 0 ' portb.2=0
number = Ow_Read(PORTB, 4)
number = number + (Ow_Read(PORTB, 4) << 8)

number = (number /2)/ 29.1

wordToStr(number, ch)
Lcd_Out(2,8,ch)
delay_us(500)
wend
' Main program
end.

David Lemmen
Davidlemmen

posted on 2013/02/04 08:20:22 AM CET

Audio & Speech

AVR multiple audio track access

Can anyone supply an example of how to get the demo mp3 player to play back more than the one file it currently plays. Seems to do with the global variable mp3_filename. Removing this file causes it to not play. I was not able to get the program to load another file from a local variable. Any help would be appreciated.....

Willy Lievens
willy.zon

posted on 2013/02/01 10:42:30 AM CET

Communication > USB

Menu Tools USART Terminal for USB-communication

Hello,

I work with EasyPIC-7/MikroC PRO for PIC/16F887, a wonderful platform!
My PC has no tradional RS232 COM-port (DSUB-9).
So, I want to use the USB UART (at the left side of the 4x7-segment display)
My PC recognice the USB-connection with the build-in USART Terminal (on USB/COM-3).
There is communication... but the program doesn't work. I receive only strange characters.
The USART-terminal settings for this are:
Bits per second: 9600, Data Bits: 8, Parity: None, Stop bits: 1, Flow control: None.
What's my problem?

Can you help me?
Willy

void newline()
{
UART1_Write(13); // Carriage Return
UART1_Write(10); // Line Feed
}

void main()
{
unsigned char MyError, Temp;

ANSEL = ANSELH = 0x00;
C1ON_bit = C2ON_bit = 0; // Disable Comparators
TRISB = 0b00000010;
UART1_Init(9600);
Delay_ms(100);
UART1_Write_Text("Testing UART! ");
newline();

do
{
UART1_Write_Text("Type in a Number: ");
while(!UART1_Data_Ready());
Temp = UART1_Read();
newline();
UART1_Write_Text("You entered: ");
UART1_Write(Temp);
newline();
} while(1);
} // End main()

krish na
rishkan

posted on 2013/01/30 11:25:52 PM CET

Other Codes

need code in microc

hi,
i nee code in microc for the following
2 toggle switches and 8 leds
sw1 and sw2 off means = all leds off
if sw1 on - led1 on- 5 millisecond delay-led2 on- 5 millisecond delay-led 3 on-1millisecond delay-led3 off-10 millisecond delay- led4 on 1msec delay -led4 off. thishould repeat in loop and should also check if sw2 is on if it is on then all led off
the same for if sw2on.

first | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 last