microcontroller-111 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. microcontroller_111/__init__.py +4 -0
  2. microcontroller_111/core.py +25 -0
  3. microcontroller_111/data/01_8051_Timer_0_1_kHz_Square_Wave.txt +24 -0
  4. microcontroller_111/data/02_8051_Timer_1_500_Hz_and_1_kHz_Sequential.txt +47 -0
  5. microcontroller_111/data/03_8051_Hybrid_Waveform_400_Hz_900_Hz.txt +46 -0
  6. microcontroller_111/data/04_8051_UART_Transmit_Name.txt +45 -0
  7. microcontroller_111/data/05_8051_UART_Transmit_Name_and_Roll_Number.txt +45 -0
  8. microcontroller_111/data/06_PIC_Addition_of_Two_8_bit_Numbers.txt +17 -0
  9. microcontroller_111/data/07_PIC_Subtraction_of_Two_8_bit_Numbers.txt +23 -0
  10. microcontroller_111/data/08_PIC_Block_Data_Transfer.txt +33 -0
  11. microcontroller_111/data/09_PIC_Timer_Delay_LED_Toggle.txt +37 -0
  12. microcontroller_111/data/10_PIC_Up_Down_Counter_on_LEDs.txt +45 -0
  13. microcontroller_111/data/11_PIC_Start_Reset_8_bit_Up_Counter.txt +60 -0
  14. microcontroller_111/data/12_PIC_Shifting_LED_LSB_MSB.txt +63 -0
  15. microcontroller_111/data/13_PIC_LCD_Name_and_Roll_Number.txt +67 -0
  16. microcontroller_111/data/14_PIC_LCD_MICROCONTROLLER_LAB_ESE.txt +67 -0
  17. microcontroller_111/data/15_PIC_ADC_Threshold_LED_Control.txt +37 -0
  18. microcontroller_111/data/16_PIC_ADC_Display_Digital_Value.txt +61 -0
  19. microcontroller_111/data/17_PIC_LCD_Counter_00_99.txt +60 -0
  20. microcontroller_111/data/18_PIC_4x4_Keypad_Display_Key_on_LCD.txt +105 -0
  21. microcontroller_111/data/19_PIC_Keypad_Four_Successive_Keys.txt +119 -0
  22. microcontroller_111/data/20_PIC_Keypad_Digit_and_ASCII_Code.txt +118 -0
  23. microcontroller_111/data/21_PIC_Keypad_VALID_FUNCTION.txt +120 -0
  24. microcontroller_111/data/22_PIC_Stepper_Motor_Clockwise.txt +25 -0
  25. microcontroller_111/data/23_PIC_Stepper_Motor_Anticlockwise.txt +25 -0
  26. microcontroller_111/data/24_PIC_Stepper_Motor_Direction_by_Push_Buttons.txt +40 -0
  27. microcontroller_111/data/25_PIC_Stepper_Motor_One_Revolution_CW_then_CCW.txt +46 -0
  28. microcontroller_111/data/26_ARM_LPC2148_Addition_of_Two_32_bit_Numbers.txt +11 -0
  29. microcontroller_111/data/27_ARM_LPC2148_Subtraction_of_Two_32_bit_Numbers.txt +11 -0
  30. microcontroller_111/data/28_ARM_LPC2148_AND_OR_XOR_Operations.txt +14 -0
  31. microcontroller_111/data/29_ARM_LPC2148_7_Segment_Up_Counter_00_99.txt +41 -0
  32. microcontroller_111/data/30_ARM_LPC2148_7_Segment_Down_Counter_99_00.txt +41 -0
  33. microcontroller_111/data/31_ARM_LPC2148_7_Segment_Display_a_Two_Digit_Number.txt +35 -0
  34. microcontroller_111/data/32_ARM_LPC2148_7_Segment_Alternate_Patterns.txt +43 -0
  35. microcontroller_111/data/33_ARM_LPC2148_ADC_Value_on_Serial_Terminal.txt +39 -0
  36. microcontroller_111/data/34_ARM_LPC2148_ADC_Count_and_Voltage_on_Serial_Terminal.txt +37 -0
  37. microcontroller_111/data/35_ARM_LPC2148_ADC_Threshold_LOW_HIGH_on_Serial.txt +40 -0
  38. microcontroller_111/data/36_ARM_LPC2148_ADC_Count_and_Voltage_on_LCD.txt +77 -0
  39. microcontroller_111/data/37_ARM_LPC2148_RTC_Hours_Minutes_Seconds_on_LCD.txt +89 -0
  40. microcontroller_111/data/38_ARM_LPC2148_RTC_Date_and_Time_on_LCD.txt +96 -0
  41. microcontroller_111/data/39_ARM_LPC2148_RTC_Alarm_with_LED.txt +108 -0
  42. microcontroller_111/data/40_ARM_LPC2148_RTC_Time_with_LED_at_30_Seconds.txt +95 -0
  43. microcontroller_111-0.1.0.dist-info/METADATA +24 -0
  44. microcontroller_111-0.1.0.dist-info/RECORD +47 -0
  45. microcontroller_111-0.1.0.dist-info/WHEEL +5 -0
  46. microcontroller_111-0.1.0.dist-info/licenses/LICENSE +3 -0
  47. microcontroller_111-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,37 @@
1
+ #include <xc.h>
2
+
3
+ #define _XTAL_FREQ 20000000UL
4
+
5
+ #define THRESHOLD 512 // about 2.5 V (512/1023 x 5 V)
6
+
7
+ unsigned int ADC_Read(void)
8
+ {
9
+ __delay_us(20); // acquisition time
10
+ ADCON0bits.GO_nDONE = 1; // start conversion
11
+ while(ADCON0bits.GO_nDONE == 1); // wait until done
12
+ return ((ADRESH << 8) | ADRESL); // 10-bit result
13
+ }
14
+
15
+ void main(void)
16
+ {
17
+ unsigned int value;
18
+
19
+ TRISB = 0x00; // PORTB = output (LED on RB0)
20
+ LATB = 0x00;
21
+
22
+ TRISEbits.TRISE2 = 1; // RE2/AN7 = input
23
+
24
+ ADCON1 = 0x07; // AN0-AN7 analog, Vref = VDD/VSS
25
+ ADCON0 = 0x1D; // channel AN7, ADC ON
26
+ ADCON2 = 0x96; // right justified, 4 TAD, Fosc/64
27
+
28
+ while(1)
29
+ {
30
+ value = ADC_Read();
31
+
32
+ if(value > THRESHOLD)
33
+ LATBbits.LATB0 = 1; // LED ON
34
+ else
35
+ LATBbits.LATB0 = 0; // LED OFF
36
+ }
37
+ }
@@ -0,0 +1,61 @@
1
+ #include <xc.h>
2
+
3
+ #define _XTAL_FREQ 20000000UL
4
+
5
+ #define LCD_RS LATAbits.LATA0
6
+ #define LCD_E LATAbits.LATA1
7
+
8
+ void LCD_Command(unsigned char cmd)
9
+ {
10
+ LATB = cmd;
11
+ LCD_RS = 0;
12
+ LCD_E = 1;
13
+ __delay_ms(2);
14
+ LCD_E = 0;
15
+ __delay_ms(2);
16
+ }
17
+
18
+ void LCD_Data(unsigned char data)
19
+ {
20
+ LATB = data;
21
+ LCD_RS = 1;
22
+ LCD_E = 1;
23
+ __delay_ms(2);
24
+ LCD_E = 0;
25
+ __delay_ms(2);
26
+ }
27
+
28
+ void main(void)
29
+ {
30
+ unsigned int value;
31
+
32
+ TRISB = 0x00; // LCD data
33
+ TRISAbits.TRISA0 = 0; // RS
34
+ TRISAbits.TRISA1 = 0; // E
35
+ TRISEbits.TRISE2 = 1; // AN7 input (pot)
36
+
37
+ ADCON1 = 0x07; // AN0-AN7 analog
38
+ ADCON0 = 0x1D; // select AN7, ADC ON
39
+ ADCON2 = 0x96; // right justified
40
+
41
+ __delay_ms(20);
42
+ LCD_Command(0x38); // 8-bit, 2 lines
43
+ LCD_Command(0x0C); // display ON
44
+ LCD_Command(0x01); // clear
45
+ __delay_ms(5);
46
+
47
+ while(1)
48
+ {
49
+ ADCON0bits.GO_nDONE = 1; // start conversion
50
+ while(ADCON0bits.GO_nDONE == 1); // wait
51
+ value = (ADRESH << 8) | ADRESL; // 0 - 1023
52
+
53
+ LCD_Command(0x80); // line 1
54
+ LCD_Data(value / 1000 + '0'); // thousands
55
+ LCD_Data(value / 100 % 10 + '0'); // hundreds
56
+ LCD_Data(value / 10 % 10 + '0'); // tens
57
+ LCD_Data(value % 10 + '0'); // units
58
+
59
+ __delay_ms(200);
60
+ }
61
+ }
@@ -0,0 +1,60 @@
1
+ #include <xc.h>
2
+
3
+ #define _XTAL_FREQ 20000000UL
4
+
5
+ #define LCD_RS LATAbits.LATA0
6
+ #define LCD_E LATAbits.LATA1
7
+
8
+ void LCD_Command(unsigned char cmd)
9
+ {
10
+ LATB = cmd;
11
+ LCD_RS = 0;
12
+ LCD_E = 1;
13
+ __delay_ms(2);
14
+ LCD_E = 0;
15
+ __delay_ms(2);
16
+ }
17
+
18
+ void LCD_Data(unsigned char data)
19
+ {
20
+ LATB = data;
21
+ LCD_RS = 1;
22
+ LCD_E = 1;
23
+ __delay_ms(2);
24
+ LCD_E = 0;
25
+ __delay_ms(2);
26
+ }
27
+
28
+ void main(void)
29
+ {
30
+ unsigned char count;
31
+
32
+ ADCON1 = 0x0F; // make pins digital
33
+ TRISB = 0x00; // LCD data
34
+ TRISAbits.TRISA0 = 0; // RS
35
+ TRISAbits.TRISA1 = 0; // E
36
+
37
+ __delay_ms(20);
38
+ LCD_Command(0x38); // 8-bit, 2 lines
39
+ LCD_Command(0x0C); // display ON, cursor OFF
40
+ LCD_Command(0x01); // clear
41
+ __delay_ms(5);
42
+
43
+ LCD_Command(0x80); // line 1
44
+ LCD_Data('C');
45
+ LCD_Data('O');
46
+ LCD_Data('U');
47
+ LCD_Data('N');
48
+ LCD_Data('T');
49
+
50
+ while(1)
51
+ {
52
+ for(count = 0; count <= 99; count++)
53
+ {
54
+ LCD_Command(0xC0); // line 2, position 1
55
+ LCD_Data(count / 10 + '0'); // tens digit
56
+ LCD_Data(count % 10 + '0'); // units digit
57
+ __delay_ms(500);
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,105 @@
1
+ #include <xc.h>
2
+
3
+ #define _XTAL_FREQ 20000000UL
4
+
5
+ #define LCD_RS LATAbits.LATA0
6
+ #define LCD_E LATAbits.LATA1
7
+
8
+ const char keymap[4][4] =
9
+ {
10
+ {'1','2','3','A'},
11
+ {'4','5','6','B'},
12
+ {'7','8','9','C'},
13
+ {'*','0','#','D'}
14
+ };
15
+
16
+ void LCD_Command(unsigned char cmd)
17
+ {
18
+ LATB = cmd;
19
+ LCD_RS = 0;
20
+ LCD_E = 1;
21
+ __delay_ms(2);
22
+ LCD_E = 0;
23
+ __delay_ms(2);
24
+ }
25
+
26
+ void LCD_Data(unsigned char data)
27
+ {
28
+ LATB = data;
29
+ LCD_RS = 1;
30
+ LCD_E = 1;
31
+ __delay_ms(2);
32
+ LCD_E = 0;
33
+ __delay_ms(2);
34
+ }
35
+
36
+ char Keypad_GetKey(void)
37
+ {
38
+ unsigned char row, col;
39
+
40
+ for(row = 0; row < 4; row++)
41
+ {
42
+ LATD = 0x0F; // RD0-RD3 all HIGH
43
+ LATD = LATD & ~(1 << row); // make one line LOW
44
+ __delay_us(100);
45
+
46
+ for(col = 0; col < 4; col++)
47
+ {
48
+ if((PORTD & (0x10 << col)) == 0) // RD4..RD7 LOW?
49
+ {
50
+ __delay_ms(20); // debounce
51
+ if((PORTD & (0x10 << col)) == 0)
52
+ {
53
+ while((PORTD & (0x10 << col)) == 0); // wait release
54
+ return keymap[row][col]; // ASCII of key
55
+ }
56
+ }
57
+ }
58
+ }
59
+ return 0; // no key pressed
60
+ }
61
+
62
+ void main(void)
63
+ {
64
+ char key;
65
+ unsigned char pos = 0;
66
+
67
+ ADCON1 = 0x0F; // make pins digital
68
+
69
+ TRISB = 0x00; // LCD data
70
+ TRISAbits.TRISA0 = 0; // RS
71
+ TRISAbits.TRISA1 = 0; // E
72
+
73
+ TRISD = 0xF0; // RD0-RD3 output, RD4-RD7 input
74
+ LATD = 0x0F;
75
+
76
+ __delay_ms(20);
77
+ LCD_Command(0x38); // 8-bit, 2 lines
78
+ LCD_Command(0x0C); // display ON
79
+ LCD_Command(0x01); // clear
80
+ __delay_ms(5);
81
+ LCD_Command(0x06); // auto-increment
82
+ LCD_Command(0x80); // line 1
83
+
84
+ while(1)
85
+ {
86
+ key = Keypad_GetKey();
87
+
88
+ if(key != 0)
89
+ {
90
+ LCD_Data(key); // display the character
91
+ pos++;
92
+
93
+ if(pos == 16) // line 1 full -> go to line 2
94
+ LCD_Command(0xC0);
95
+
96
+ if(pos == 32) // screen full -> clear
97
+ {
98
+ LCD_Command(0x01);
99
+ __delay_ms(5);
100
+ LCD_Command(0x80);
101
+ pos = 0;
102
+ }
103
+ }
104
+ }
105
+ }
@@ -0,0 +1,119 @@
1
+ #include <xc.h>
2
+
3
+ #define _XTAL_FREQ 20000000UL
4
+
5
+ #define LCD_RS LATAbits.LATA0
6
+ #define LCD_E LATAbits.LATA1
7
+
8
+ const char keymap[4][4] =
9
+ {
10
+ {'1','2','3','A'},
11
+ {'4','5','6','B'},
12
+ {'7','8','9','C'},
13
+ {'*','0','#','D'}
14
+ };
15
+
16
+ void LCD_Command(unsigned char cmd)
17
+ {
18
+ LATB = cmd;
19
+ LCD_RS = 0;
20
+ LCD_E = 1;
21
+ __delay_ms(2);
22
+ LCD_E = 0;
23
+ __delay_ms(2);
24
+ }
25
+
26
+ void LCD_Data(unsigned char data)
27
+ {
28
+ LATB = data;
29
+ LCD_RS = 1;
30
+ LCD_E = 1;
31
+ __delay_ms(2);
32
+ LCD_E = 0;
33
+ __delay_ms(2);
34
+ }
35
+
36
+ char Keypad_GetKey(void)
37
+ {
38
+ unsigned char row, col;
39
+
40
+ for(row = 0; row < 4; row++)
41
+ {
42
+ LATD = 0x0F; // RD0-RD3 all HIGH
43
+ LATD = LATD & ~(1 << row); // make one line LOW
44
+ __delay_us(100);
45
+
46
+ for(col = 0; col < 4; col++)
47
+ {
48
+ if((PORTD & (0x10 << col)) == 0) // RD4..RD7 LOW?
49
+ {
50
+ __delay_ms(20); // debounce
51
+ if((PORTD & (0x10 << col)) == 0)
52
+ {
53
+ while((PORTD & (0x10 << col)) == 0); // wait release
54
+ return keymap[row][col];
55
+ }
56
+ }
57
+ }
58
+ }
59
+ return 0; // no key pressed
60
+ }
61
+
62
+ void main(void)
63
+ {
64
+ char keys[4]; // stores 4 key presses
65
+ unsigned char i;
66
+
67
+ ADCON1 = 0x0F; // make pins digital
68
+
69
+ TRISB = 0x00; // LCD data
70
+ TRISAbits.TRISA0 = 0; // RS
71
+ TRISAbits.TRISA1 = 0; // E
72
+
73
+ TRISD = 0xF0; // RD0-RD3 output, RD4-RD7 input
74
+ LATD = 0x0F;
75
+
76
+ __delay_ms(20);
77
+ LCD_Command(0x38); // 8-bit, 2 lines
78
+ LCD_Command(0x0C); // display ON
79
+ LCD_Command(0x01); // clear
80
+ __delay_ms(5);
81
+ LCD_Command(0x06); // auto-increment
82
+
83
+ while(1)
84
+ {
85
+ LCD_Command(0x01); // clear screen
86
+ __delay_ms(5);
87
+ LCD_Command(0x80); // line 1
88
+ LCD_Data('E');
89
+ LCD_Data('N');
90
+ LCD_Data('T');
91
+ LCD_Data('E');
92
+ LCD_Data('R');
93
+ LCD_Data(' ');
94
+ LCD_Data('4');
95
+ LCD_Data(' ');
96
+ LCD_Data('K');
97
+ LCD_Data('E');
98
+ LCD_Data('Y');
99
+ LCD_Data('S');
100
+
101
+ // Read 4 successive key presses
102
+ for(i = 0; i < 4; i++)
103
+ {
104
+ do
105
+ {
106
+ keys[i] = Keypad_GetKey();
107
+ } while(keys[i] == 0); // wait until a key is pressed
108
+ }
109
+
110
+ // Display the 4 entered characters
111
+ LCD_Command(0xC0); // line 2
112
+ for(i = 0; i < 4; i++)
113
+ {
114
+ LCD_Data(keys[i]);
115
+ }
116
+
117
+ __delay_ms(3000); // show for 3 s, then repeat
118
+ }
119
+ }
@@ -0,0 +1,118 @@
1
+ #include <xc.h>
2
+
3
+ #define _XTAL_FREQ 20000000UL
4
+
5
+ #define LCD_RS LATAbits.LATA0
6
+ #define LCD_E LATAbits.LATA1
7
+
8
+ const char keymap[4][4] =
9
+ {
10
+ {'1','2','3','A'},
11
+ {'4','5','6','B'},
12
+ {'7','8','9','C'},
13
+ {'*','0','#','D'}
14
+ };
15
+
16
+ void LCD_Command(unsigned char cmd)
17
+ {
18
+ LATB = cmd;
19
+ LCD_RS = 0;
20
+ LCD_E = 1;
21
+ __delay_ms(2);
22
+ LCD_E = 0;
23
+ __delay_ms(2);
24
+ }
25
+
26
+ void LCD_Data(unsigned char data)
27
+ {
28
+ LATB = data;
29
+ LCD_RS = 1;
30
+ LCD_E = 1;
31
+ __delay_ms(2);
32
+ LCD_E = 0;
33
+ __delay_ms(2);
34
+ }
35
+
36
+ void LCD_String(const char *str)
37
+ {
38
+ while(*str != '\0')
39
+ {
40
+ LCD_Data(*str);
41
+ str++;
42
+ }
43
+ }
44
+
45
+ char Keypad_GetKey(void)
46
+ {
47
+ unsigned char row, col;
48
+
49
+ for(row = 0; row < 4; row++)
50
+ {
51
+ LATD = 0x0F; // RD0-RD3 all HIGH
52
+ LATD = LATD & ~(1 << row); // make one line LOW
53
+ __delay_us(100);
54
+
55
+ for(col = 0; col < 4; col++)
56
+ {
57
+ if((PORTD & (0x10 << col)) == 0) // RD4..RD7 LOW?
58
+ {
59
+ __delay_ms(20); // debounce
60
+ if((PORTD & (0x10 << col)) == 0)
61
+ {
62
+ while((PORTD & (0x10 << col)) == 0); // wait release
63
+ return keymap[row][col];
64
+ }
65
+ }
66
+ }
67
+ }
68
+ return 0;
69
+ }
70
+
71
+ void main(void)
72
+ {
73
+ char key;
74
+
75
+ ADCON1 = 0x0F; // make pins digital
76
+
77
+ TRISB = 0x00; // LCD data
78
+ TRISAbits.TRISA0 = 0; // RS
79
+ TRISAbits.TRISA1 = 0; // E
80
+
81
+ TRISD = 0xF0; // RD0-RD3 output, RD4-RD7 input
82
+ LATD = 0x0F;
83
+
84
+ __delay_ms(20);
85
+ LCD_Command(0x38); // 8-bit, 2 lines
86
+ LCD_Command(0x0C); // display ON
87
+ LCD_Command(0x01); // clear
88
+ __delay_ms(5);
89
+ LCD_Command(0x06); // auto-increment
90
+
91
+ LCD_Command(0x80);
92
+ LCD_String("PRESS A DIGIT");
93
+
94
+ while(1)
95
+ {
96
+ key = Keypad_GetKey();
97
+
98
+ if(key >= '0' && key <= '9') // only numeric keys
99
+ {
100
+ LCD_Command(0x01); // clear
101
+ __delay_ms(5);
102
+
103
+ // Line 1: the digit
104
+ LCD_Command(0x80);
105
+ LCD_String("DIGIT: ");
106
+ LCD_Data(key);
107
+
108
+ // Line 2: ASCII code in decimal and hex
109
+ LCD_Command(0xC0);
110
+ LCD_String("ASCII:");
111
+ LCD_Data(key / 10 + '0'); // decimal tens (48-57)
112
+ LCD_Data(key % 10 + '0'); // decimal units
113
+ LCD_String(" 0x");
114
+ LCD_Data(key / 16 + '0'); // hex high digit (always 3)
115
+ LCD_Data(key % 16 + '0'); // hex low digit (0-9)
116
+ }
117
+ }
118
+ }
@@ -0,0 +1,120 @@
1
+ #include <xc.h>
2
+
3
+ #define _XTAL_FREQ 20000000UL
4
+
5
+ #define LCD_RS LATAbits.LATA0
6
+ #define LCD_E LATAbits.LATA1
7
+
8
+ const char keymap[4][4] =
9
+ {
10
+ {'1','2','3','A'},
11
+ {'4','5','6','B'},
12
+ {'7','8','9','C'},
13
+ {'*','0','#','D'}
14
+ };
15
+
16
+ void LCD_Command(unsigned char cmd)
17
+ {
18
+ LATB = cmd;
19
+ LCD_RS = 0;
20
+ LCD_E = 1;
21
+ __delay_ms(2);
22
+ LCD_E = 0;
23
+ __delay_ms(2);
24
+ }
25
+
26
+ void LCD_Data(unsigned char data)
27
+ {
28
+ LATB = data;
29
+ LCD_RS = 1;
30
+ LCD_E = 1;
31
+ __delay_ms(2);
32
+ LCD_E = 0;
33
+ __delay_ms(2);
34
+ }
35
+
36
+ void LCD_String(const char *str)
37
+ {
38
+ while(*str != '\0')
39
+ {
40
+ LCD_Data(*str);
41
+ str++;
42
+ }
43
+ }
44
+
45
+ char Keypad_GetKey(void)
46
+ {
47
+ unsigned char row, col;
48
+
49
+ for(row = 0; row < 4; row++)
50
+ {
51
+ LATD = 0x0F; // RD0-RD3 all HIGH
52
+ LATD = LATD & ~(1 << row); // make one line LOW
53
+ __delay_us(100);
54
+
55
+ for(col = 0; col < 4; col++)
56
+ {
57
+ if((PORTD & (0x10 << col)) == 0) // RD4..RD7 LOW?
58
+ {
59
+ __delay_ms(20); // debounce
60
+ if((PORTD & (0x10 << col)) == 0)
61
+ {
62
+ while((PORTD & (0x10 << col)) == 0); // wait release
63
+ return keymap[row][col];
64
+ }
65
+ }
66
+ }
67
+ }
68
+ return 0;
69
+ }
70
+
71
+ void main(void)
72
+ {
73
+ char key;
74
+
75
+ ADCON1 = 0x0F; // make pins digital
76
+
77
+ TRISB = 0x00; // LCD data
78
+ TRISAbits.TRISA0 = 0; // RS
79
+ TRISAbits.TRISA1 = 0; // E
80
+
81
+ TRISD = 0xF0; // RD0-RD3 output, RD4-RD7 input
82
+ LATD = 0x0F;
83
+
84
+ __delay_ms(20);
85
+ LCD_Command(0x38); // 8-bit, 2 lines
86
+ LCD_Command(0x0C); // display ON
87
+ LCD_Command(0x01); // clear
88
+ __delay_ms(5);
89
+ LCD_Command(0x06); // auto-increment
90
+
91
+ LCD_Command(0x80);
92
+ LCD_String("PRESS A KEY");
93
+
94
+ while(1)
95
+ {
96
+ key = Keypad_GetKey();
97
+
98
+ if(key >= '0' && key <= '9') // numeric key
99
+ {
100
+ LCD_Command(0x01);
101
+ __delay_ms(5);
102
+ LCD_Command(0x80);
103
+ LCD_String("VALID");
104
+ LCD_Command(0xC0);
105
+ LCD_String("KEY: ");
106
+ LCD_Data(key);
107
+ }
108
+ else if(key >= 'A' && key <= 'D') // function key
109
+ {
110
+ LCD_Command(0x01);
111
+ __delay_ms(5);
112
+ LCD_Command(0x80);
113
+ LCD_String("FUNCTION");
114
+ LCD_Command(0xC0);
115
+ LCD_String("KEY: ");
116
+ LCD_Data(key);
117
+ }
118
+ // '*' and '#' are ignored
119
+ }
120
+ }
@@ -0,0 +1,25 @@
1
+ #include <xc.h>
2
+
3
+ #define _XTAL_FREQ 20000000UL
4
+
5
+ void main(void)
6
+ {
7
+ TRISC = 0x00; // PORTC = output (motor driver)
8
+ LATC = 0x00;
9
+
10
+ while(1)
11
+ {
12
+ // Clockwise sequence: 03 -> 06 -> 24 -> 21
13
+ LATC = 0x03; // RC0 + RC1
14
+ __delay_ms(5);
15
+
16
+ LATC = 0x06; // RC1 + RC2
17
+ __delay_ms(5);
18
+
19
+ LATC = 0x24; // RC2 + RC5
20
+ __delay_ms(5);
21
+
22
+ LATC = 0x21; // RC5 + RC0
23
+ __delay_ms(5);
24
+ }
25
+ }
@@ -0,0 +1,25 @@
1
+ #include <xc.h>
2
+
3
+ #define _XTAL_FREQ 20000000UL
4
+
5
+ void main(void)
6
+ {
7
+ TRISC = 0x00; // PORTC = output (motor driver)
8
+ LATC = 0x00;
9
+
10
+ while(1)
11
+ {
12
+ // Anticlockwise sequence: 21 -> 24 -> 06 -> 03
13
+ LATC = 0x21; // RC5 + RC0
14
+ __delay_ms(5);
15
+
16
+ LATC = 0x24; // RC2 + RC5
17
+ __delay_ms(5);
18
+
19
+ LATC = 0x06; // RC1 + RC2
20
+ __delay_ms(5);
21
+
22
+ LATC = 0x03; // RC0 + RC1
23
+ __delay_ms(5);
24
+ }
25
+ }