C Language: Write a diagnostic code for the following code. And please tell me what it will check for. This code does the following: its using 2 7 Segment LEDs
Hit Switch
Count Up
Hit Switch
Display Time
Hit Switch
Count Down from 99
Hit Switch
Display time
Hit Switch
Turn off display
The diagonistic code should check: All segement of the LEDs and or buttons to make sure they work fine.
#include
#include
#include
#include
#include "LabJackUD.h"
#include "LJUD_DynamicLinking.h"
void ErrorHandler (LJ_ERROR ljError, long lngLineNumber)
{
char err[255];
if (ljError != LJE_NOERROR)
{
ErrorToString(ljError,
err);
printf("Error # %ld:
%s\n", ljError, err);
printf("Source line
number = %ld\n", lngLineNumber);
if(ljError >
LJE_MIN_GROUP_ERROR)
{
getchar();
exit(0); // Quit if serious error
}
}
}
const int numbers[10][1] =
{
// 1: segment lit, 0: segment unlit
// a b
c d e f g
{64}, //0 1, 1, 1, 1, 1, 1, 0
1000000
{121}, //1 0, 1, 1, 0, 0, 0, 0 1111001
{36}, //2 1, 1, 0, 1, 1, 0, 1
0100100
{48}, //3 1, 1, 1, 1, 0, 0, 1
0110000
{25}, //4 0, 1, 1, 0, 0, 1, 1
0011001
{18}, //5 1, 0, 1, 1, 0, 1, 1
0010010
{2}, //6 1, 0, 1, 1, 1, 1, 1
0000010
{120}, //7 1, 1, 1, 0, 0, 0, 0 1111000
{0}, //8 1, 1, 1, 1, 1, 1, 1
0000000
{24} //9 1, 1, 1, 0, 0, 1, 1
0011000
};
int i=0;
int j=0;
int k=0;
int l=0;
int m=0;
double ReadVal=1;
main()
{
LJ_ERROR ljError; // LabJack error code
LJ_HANDLE ljHandle = 0; // ID# assigned to the
opened LabJack
LoadLabJackUD(); // Load the LabJack DLL
// Open the first found LabJack U3
ljError = OpenLabJack (LJ_dtU3, LJ_ctUSB, "1",
1, &ljHandle);
ErrorHandler(ljError, __LINE__);
// Set all pin assignments to the factory default
condition
ljError = ePut(ljHandle,
LJ_ioPIN_CONFIGURATION_RESET, 0, 0, 0);
ErrorHandler(ljError, __LINE__);
{
while (ReadVal==1)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
while
(ReadVal==0)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
while (m < 3300
&& ReadVal==1)
{
i=k/330;
j=l/33;
if (j==10)
l=0;
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[i][0],
7);
Sleep(1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[j][0],
7);
Sleep(1);
k++;
l++;
m++;
}
while
(ReadVal==0)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
while (ReadVal==1)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[i][0],
7);
Sleep(12);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[j][0],
7);
Sleep(12);
}
while
(ReadVal==0)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
m=3300;
k=3300;
l=330;
while (ReadVal==1
&& m > 0)
{
i=k/330;
j=l/33;
if (l==0)
l=330;
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[i][0],
7);
Sleep(1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[j][0],
7);
Sleep(1);
k--;
l--;
m--;
}
while
(ReadVal==0)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
while
(ReadVal==1)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[i][0],
7);
Sleep(12);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[j][0],
7);
Sleep(12);
}
ljError =
ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle,
LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
return 0;
}
}
#include
#include
#include
#include
#include "LabJackUD.h"
#include "LJUD_DynamicLinking.h"
void ErrorHandler (LJ_ERROR ljError, long lngLineNumber)
{
char err[255];
if (ljError != LJE_NOERROR)
{
ErrorToString(ljError,
err);
printf("Error # %ld:
%s\n", ljError, err);
printf("Source line
number = %ld\n", lngLineNumber);
if(ljError >
LJE_MIN_GROUP_ERROR)
{
getchar();
exit(0); // Quit if serious error
}
}
}
const int numbers[10][1] =
{
// 1: segment lit, 0: segment unlit
// a b
c d e f g
{64}, //0 1, 1, 1, 1, 1, 1, 0
1000000
{121}, //1 0, 1, 1, 0, 0, 0, 0 1111001
{36}, //2 1, 1, 0, 1, 1, 0, 1
0100100
{48}, //3 1, 1, 1, 1, 0, 0, 1
0110000
{25}, //4 0, 1, 1, 0, 0, 1, 1
0011001
{18}, //5 1, 0, 1, 1, 0, 1, 1
0010010
{2}, //6 1, 0, 1, 1, 1, 1, 1
0000010
{120}, //7 1, 1, 1, 0, 0, 0, 0 1111000
{0}, //8 1, 1, 1, 1, 1, 1, 1
0000000
{24} //9 1, 1, 1, 0, 0, 1, 1
0011000
};
int i=0;
int j=0;
int k=0;
int l=0;
int m=0;
double ReadVal=1;
main()
{
LJ_ERROR ljError; // LabJack error code
LJ_HANDLE ljHandle = 0; // ID# assigned to the
opened LabJack
LoadLabJackUD(); // Load the LabJack DLL
// Open the first found LabJack U3
ljError = OpenLabJack (LJ_dtU3, LJ_ctUSB, "1",
1, &ljHandle);
ErrorHandler(ljError, __LINE__);
// Set all pin assignments to the factory default
condition
ljError = ePut(ljHandle,
LJ_ioPIN_CONFIGURATION_RESET, 0, 0, 0);
ErrorHandler(ljError, __LINE__);
{
while (ReadVal==1)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
while
(ReadVal==0)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
while (m < 3300
&& ReadVal==1)
{
i=k/330;
j=l/33;
if (j==10)
l=0;
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[i][0],
7);
Sleep(1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[j][0],
7);
Sleep(1);
k++;
l++;
m++;
}
while
(ReadVal==0)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
while (ReadVal==1)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[i][0],
7);
Sleep(12);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[j][0],
7);
Sleep(12);
}
while
(ReadVal==0)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
m=3300;
k=3300;
l=330;
while (ReadVal==1
&& m > 0)
{
i=k/330;
j=l/33;
if (l==0)
l=330;
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[i][0],
7);
Sleep(1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[j][0],
7);
Sleep(1);
k--;
l--;
m--;
}
while
(ReadVal==0)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
}
while
(ReadVal==1)
{
ljError = eGet (ljHandle, LJ_ioGET_DIGITAL_BIT, 11, &ReadVal,
1);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[i][0],
7);
Sleep(12);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 8, 1, 0);
ljError = ePut(ljHandle, LJ_ioPUT_DIGITAL_PORT, 0, numbers[j][0],
7);
Sleep(12);
}
ljError =
ePut(ljHandle, LJ_ioPUT_DIGITAL_BIT, 7, 0, 0);
ljError = ePut(ljHandle,
LJ_ioPUT_DIGITAL_BIT, 8, 0, 0);
return 0;
}
}
C Language: Write a diagnostic code for the following code. And please tell me what it...
Help me to fix this code in C language. This code converts infix expressions to postfix and then evaluate the expression. Right now, it works with single digits. I need to modify it so that it can evaluate expressions with also 2 digits, example: (60+82)%72. Additionally I need to display an error when the parenthesis don't match like (89+8(. I have muted some line that would print the postfix expression with a space like: 22 8 + when the input...
How would I be able to get a Merge Sort to run in this code? MY CODE: #include <iostream> #include <fstream> #include <stdlib.h> #include <stdio.h> #include <time.h> using namespace std; class mergersorter { private: float array[1000] ; int n = 1000; int i=0; public: void fillArray() { for(i=1;i<=n;i++) { array[i-1]= ( rand() % ( 1000) )+1; } } void arrayout () { ...
should be in C language What is the output of the following segment of C code: void CapsLetter (char* x, charl); int main() { char* text; text="This is some sample text."; CapsLetter(text, 'e'); printf("%s", text); return 0; سی void Caps Letter (char* x, char 1) { int i=0; while (x[i]!='\0') { if (x[i]==1) x[i]=1-32; } 1. This is som sample text. 2. THIS IS SOME SAMPLE TEXT. 3. This is some sample text. 4. this is some sample text. What...
Problem #2 (20pts) Please write the MIPS assembly code corresponding to the following C code segment. Assume that f is assigned to register $s2 int Example int i, int j, int k) int f; f i+j-k-1: return fi
A) Rewrite the following pseudocode segment in C++ using the loop structures (for and while). Assume that all the variables are declared and initialized. k-G+ 13)/27 loop: if k> 10 then goto out k=k+1 i=3"k-1 goto loop I out: B) Rewrite the following code segment in C++ using the multiple-selection (switch and if-else) statements. Assume that all the variables are declared and initialized. if((k 1) || (k 2))j-2 k-1 if ((k 3) || ( ks))j - 3.k+1 if (k 4)j-4k-1...
MSP430 Misc.peripherals. Consider the following C source code. What does the code segment from lines 9 ~ 12 do? USCIA0 is configured in the UART mode. Consider the following C source code. 1. char gm1[]"MSP430"; 2. void UARTO_putdchar (char c) l 3. while (! (IFG2 & UCAOTXIFG)) UCAOTXBUF 5. while (! (IFG2 & UCAOTXIFG)) 6. UCAOTXBUF=''; 7 - 9. for (int i=0; i < 6; ¡++) { 10. ch gml [il; 11 UARTO putdchar (ch) 12. ) D. (4 points)...
1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...
Please use C programming to write a code segment as an answer. Instead of using an while-loop like the following code, please implement a code segment by using a do-while loop. What is the output of the code? #include <stdio.h> void main() { int i = 0; while (i < 5); { printf(“%d ”, ++i); } }
This question is about the Arduino code. Please complete a 4-input circuit on your Arduino. Your circuit, in addition to cycling through a binary representation of the numbers 0-15 using LEDs, should use the Serial port to output the decimal equivalent of each of the numbers in the format: Output: 15 ... if the value was 1111, and so forth. You will be asked to upload your code as well as a photo of your working breadboard circuit. Add comments...
Question 33 Consider the following code segment. String letters - ("A", "B", "C", "D"), ("E", "P", "G", "1"), ("I", "J", "K", "L"}}; for (int col = 1; col < letters[0].length; col++) for (int row - 1; row < letters.length; row++) System.out.print(letterstrow][col] + " "); System.out.println(); What is printed as a result of executing this code segment? AET PJ DHL G J K L PJ GK