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 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 last
Tomer Sonnenschien
tomersonn11

posted on 2014/07/04 03:20:23 PM CEST

Other Codes

Magic switch board for pic18f45k22

Hi everyone,

I'm trying to do a verison of mine to the magic switch board and since i'm new in this business,i would appreciate your help.
As a first stage i want to write a program which has three phases.

First phase- learning mode: the user turns on the four first bits of "PORT B" on. Each bit he turns-on does the following things: 1) turns-on one of the four first bits of "PORT C" on. (it doesn't matter which bit he touches and when, the first four bits of "PORT C" will be turned on from right to left)
2) every bit of "PORTB" will get a number from 1-4 accordingly, and the numbers will be sent into array in the order the user turned them on(For example, if the user turned on the third bit of "PORT B" first, the first member in the array will be 3) . Each time a number gets into the array it will be locked to the bit at "PORT C" which it turns-on (for example- 3 turns on the third bit of "PORT C", 1 turns-on the zero bit of "PORT C"...)

Second phase- Play back mode: now that the system knows which bit at "PORT B" lights which bit at "PORT C" each time the user will touch a bit from "PORT B" it will turn on the specific bit from "PORT C" which he was assigned to.

Third phase- Zeroing the system: after about 10 seconds the system will retrieve its Initial Settings.

Here is an example to the magic switch board: http://www.youtube.com/watch?v=0lGP8nQLANU

this is the code which i'm working in: // Magic switch board for pic18k45f22
short number,state,tmp;
int i=0;
int connect[4]={17,17,17,17}; // Array that holds the lighting sequence of LATC
int flag_0=0, flag_1=0, flag_2=0, flag_3=0;
sbit red at LATC0_BIT;
sbit green at LATC1_BIT;
sbit yellow at LATC2_BIT;
sbit blue at LATC3_BIT;

void Light(short number ) // Function that lights up LATC
{

switch(number)
{
case 1:
red=1;
yellow=green=blue=0;
break;
case 2:
red=green=1;
yellow=blue=0;
break;
case 3:
red=green=yellow=1;
blue=0;
break;
case 4:
red=green=yellow=blue=1;
break;
}
} // End of void Light function

short CountBit(short num) // Function that converts binary number to decimal number
{
short b,c;
for (b=0; num != 0; num = num >> 1)

if (num &1)
b++;
return b;
}

void Light_2(short state)
{
for (i=0;i<=3;i++)
{
tmp=state &1;
if (tmp)
Light (connect[i]);
state=state>>1;
}
}

void main()
{
ANSELC=0;
ANSELB=0;

TRISC=0;
LATC=0;
number=LATB&0X0F;

while(1)
{
while (i<=3) // The teaching stage
{
if (flag_0==0)
{
if (LATB0_BIT==1)
{
connect[i]=1;
flag_0=1;
i++;
}
}
if (flag_1==0)
{
if (LATB1_BIT==1)
{
connect[i]=2;
flag_1=1;
i++;
}
}
if (flag_2==0)
{
if (LATB2_BIT==1)
{
connect[i]=3;
flag_2=1;
i++;
}
}
if (flag_3==0)
{
if (LATB3_BIT==1)
{
connect[i]=4;
flag_3=1;
i++;
}
}
number=LATB&0X0F;
number=CountBit(number);
Light(number);
}// End of teaching stage

number=LATB&0X0F;
number=CountBit(number);
Light(number);


if (state!=PORTB)
{
state=PORTB;
Light_2(state);
}

}if (LATB==0)
red==green==yellow==blue==0;
}

thomas thong
THOMAS_THONG

posted on 2014/07/04 12:38:41 PM CEST

Other Codes

Flash memory

write flash memory with library for PIC18, it's run, but I can't read flash if I don't use library. Writing is OK
TBLPTRL = Lo(address);
TBLPTRH = Hi(address);
TBLPTRU = Higher(address);

EECON1.EEPGD = 1;
EECON1.CFGS = 0;
EECON1.WREN = 1;
EECON1.FREE = 1;
INTCON.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1.WR = 1;
INTCON.GIE = 1;
asm TBLRD*- ;

FSR0L = Lo(data_w[64]);
FSR0H = Hi(data_w[64]);

i = 0;
while (i <64) {
TABLAT = POSTINC0;
asm {
TBLWT+*
}
i++;

EECON1.EEPGD = 1;
EECON1.CFGS = 0;
EECON1.WREN = 1;
INTCON.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1.WR = 1;
}
INTCON.GIE = 1;
EECON1.WREN = 0;

INTCON = saveintcon;


Please can help me!

Owolabi Testimony
otesty

posted on 2014/07/03 06:35:03 PM CEST

Audio & Speech

Schrolling message using Atmega16

Please anyone help me with the code for 8X8 dot matrix scrolling message using atmega16L

Sandeep Rai
sandeeprai

posted on 2014/06/26 10:25:25 AM CEST

GSM / GPRS

GSM code for making call and PCP/IP connectivity with server.......

Dear All,

I am new to this community, I have a SmartG100 and EasyMX Pro V7 for STM32 ARM (STM32F107VC). I have to write code to make a call to another mobile and GPRS connectivty with PORT and TCP/IP address so that I can send/receive data from/to server. I'll appreciate your work. Thanks in advance.

DANIEL SIMIYU
dsimiyu520

posted on 2014/06/25 08:07:58 PM CEST

Audio & Speech

ELECTRIC FENCE CONTROLLER

LOOKING FOR ELECTRIC FENCE CONTROLLER PROJECT WITH( MICO CONTROLLER)
DC-DC CONVERTER-VOLTAGE CONTOL-REFERANCE-PULSE TIMER-DUMP CAPACITOR-TRIGGER TRIAC-STEPUP TRANSIFORMER
-CONTROL ON OFF
FIRMWARE/HARDWARE
PLEASE CONTACT NOW TO
dsimiyu520@gmail.com

first | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 last