.______M_u_h_a_n_d_i_s_k______.
KOMPILASI NOTA-NOTA KEHIDUPAN DAN PERINGATAN UNTUK DIRI SENDIRI
Control IC H-Bridge L293 (without PWM control)
int L2 = 4;
int L1 = 5;
int R1 = 6;
int R2 = 7;
void setup()
{
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(R1, OUTPUT);
pinMode(R2, OUTPUT);
}
void loop()
{
//TURNCW
digitalWrite(L1, HIGH); //cw right
digitalWrite(L2, LOW);
digitalWrite(R1, HIGH); //cw left
digitalWrite(R2, LOW);
delay(4000);
//TURNCCW
digitalWrite(L1, LOW); //ccw right
digitalWrite(L2, HIGH);
digitalWrite(R1, LOW); //ccw left
digitalWrite(R2, HIGH);
delay(4000);
//REVERSE
digitalWrite(L1, HIGH); //cw right
digitalWrite(L2, LOW);
digitalWrite(R1, LOW); //cww left
digitalWrite(R2, HIGH);
delay(4000);
//FOWARD
digitalWrite(L1, LOW); //cww right
digitalWrite(L2, HIGH);
digitalWrite(R1, HIGH); //cw left
digitalWrite(R2, LOW);
delay(4000);
}
Classification of Materials
Classification according to the way materials react to the current when a voltage is applied across them
Insulators
1. Materials with very high resistance
2. Oppose the flow of current (mica , rubber)
Conductors
1. Materials with very low resistance
2. Allow the current ti flow easily (copper, aluminium)
Semiconductors
1. Neither good conductors nor insulators (silicon, germanium)
2. Can be controlled to either insulators by increasing their resistance or conductors by decreasing their resistance
Insulators
1. Materials with very high resistance
2. Oppose the flow of current (mica , rubber)
Conductors
1. Materials with very low resistance
2. Allow the current ti flow easily (copper, aluminium)
Semiconductors
1. Neither good conductors nor insulators (silicon, germanium)
2. Can be controlled to either insulators by increasing their resistance or conductors by decreasing their resistance
Supplication when leaving the home
Versi Melayu
Lailahaillallah Muhammadurrasulullah
Lailahaillallah Muhammadurrasulullah
Ingat2 wahai manusia jangan kamu suka-suka
Kita mukmin dalam dunia itu lagi dipenjara
Apa kita tidak teringin mengikut pada ibu bapa
Bapa Adam ibu Hawa semua kumbali kedalam syurga
Berkumpul serta nabi kita nabi Muhammad yang mulia
Kita tinggal dalam dunia banyak musuh tak terkira
Musuh hawa nafsu syaitan mengajak pergi neraka jahanam
Supaya pisah nabi ikutan serta bapa nabi Adam
Elok kita untuk beringat penggodanya syaitan jahat
Tidak muda tidak tua semua diajak masuk neraka
Syaitan menggoda mengikut darah lagi taat yang disuruh
Pada syarak kita lupa pada dunia kita suka
Elok taat yang dijaga jangan ahli bongkak dan bangga
Dosa kita yang dihalang tidak rugi umur yang hilang
Elok kita baca selawat sembahyang fardhu juga sunat
Sertakan ikhlas pada taat semoga kita dapat rahmat
Allah berfirman dalam Quran orang yang sesat pergi jahanam
Orang yang ikut perintah tuhan bakal masuk syurga jinan
Jangan kita sukakan dunia ada hadis telah tercerita
Permulaan setiap dosa jadi menarik masuk neraka
Ingat2 wahai manusia kerana masih hidup didunia
Sucikanlah badan kita besok mati siapa yang sucikan
Ingat2wahai manusia betulkanlah mengajimu
Semasa belum kedatangan malaikat pencabut nyawa Syair Jawa yang Bapaku Ingatkan
Lailahaillallah Muhammadurrasulullah
Lailahaillallah Muhammadurrasulullah
Eleng-eleng siro menungso Ojo siro suko-suko
kito mukmin eneng dunio Iku lagi den kunjaro
Opo siro ora beronto Nusul maring ibu bopo
Bopo adam ibu howo Podo bali mareng suwargo
Kumpul serto nabi kito Nabi Muhammad kang mulio
Kito keri eneng dunyo Akeh musoh tan kiro-kiro
Musoh howo nafsune syetan Podo ngajak mareng jahanam
Supoyo pisah nabi panutan Serto bopo nabi adam
Becik siro podo ilingo Penggodane syetan igo
Orak enom orak tuo Kabeh den jak melebu neroko
Syetan gudo anurut geteh Lali tongat kang sinupereh
Mareng syarak ora noleh Mareng dunyo ngajak sugeh
Becik tongat kang rinekso Ojo ahli umuk lan kondo
Doso wuwuh dateng kerso Ora luput ngumur den sodo
Becik siro moco selawat Solat fadhu nuli sunat
Serto ekhlas dateng tongat Mbok menowo oleh rohmat
Alloh dawoh eneng Quran Wongkang lacut mareng jahanam
Wongkang nurut perentah tuhan Bakal melbu suwargo jinan
Ojo siro damen neng dunyo Ono hadis wus kecerito
Wiwitane saben olo Dadi narek melbu neroko
Eleng-eleng siro menungso Pumpung urep eneng dunyo
Suci nono badani iro Besok mati sopo kang nuceni
Eleng-eleng siro menungso Temenono gon mu ngaji
Pumpung durong ketekanan Malaikat juru pati
Split to two different array
#include <stdio.h>
int temp, array[6], n,odd=0,even=0, num_odd[6], num_even[6];
printf("Enter numbers\t: ");
for(n=0;n<6; n++)
scanf("%d", &array[n]);
for(n=0; n<6; n++){
temp=array[n]%2;
if(temp==0){
num_even[even]=array[n];
even++;}
if(temp==1){
num_odd[odd]=array[n];
odd++;}
}
printf("\nEven numbers\t: ");
for(n=0; n<even;n++){
printf("%2d", num_even[n]);
}
printf("\n");
printf("\nOdd numbers\t: ");
for(n=0; n<odd;n++){
printf("%2d", num_odd[n]);
}
printf("\n\n");
system ("pause");
return 0;
}
Array name is the same as the address of the array's first element
#include<stdio.h>
int main( void )
{
char array[5];
printf( " array = %p\n&array[0] = %p\n &array = %p\n", array, &array[0], &array );
system ("pause");
return 0;
}
Linear Searh Array
#include<stdio.h>
#define SIZE 100
int linearSearch( const int array[], int key, int size );
int main( void )
{
int a[ SIZE ];
int x;
int searchKey;
int element;
for( x = 0; x < SIZE; x++ ){
a[x] = 2 * x;
}
printf( "Enter integer search key:\n" );
scanf( "%d", &searchKey );
element = linearSearch( a, searchKey, SIZE );
if( element != -1 ){
printf( "Found value in element %d\n", element );
}
else{
printf( "Value not found\n" );
}
system ("pause");
return 0;
}
int linearSearch( const int array[], int key, int size )
{
int n;
for( n = 0; n < size; ++n ){
if( array[n] == key ){
return n;
}
}
return -1;
}
#define SIZE 100
int linearSearch( const int array[], int key, int size );
int main( void )
{
int a[ SIZE ];
int x;
int searchKey;
int element;
for( x = 0; x < SIZE; x++ ){
a[x] = 2 * x;
}
printf( "Enter integer search key:\n" );
scanf( "%d", &searchKey );
element = linearSearch( a, searchKey, SIZE );
if( element != -1 ){
printf( "Found value in element %d\n", element );
}
else{
printf( "Value not found\n" );
}
system ("pause");
return 0;
}
int linearSearch( const int array[], int key, int size )
{
int n;
for( n = 0; n < size; ++n ){
if( array[n] == key ){
return n;
}
}
return -1;
}
Graphing Array Element Values with Histograms
#include <stdio.h>
#define SIZE 10
int main(void)
{
int n[SIZE] = {19, 3, 15, 7, 11, 9, 13, 5, 17, 1};
int i;
int j;
printf("%s%13s%17s\n","Element","Value", "Histogram");
for( i=0; i<SIZE; i++){
printf("%7d%13d ", i, n[i]);
for (j=1; j<= n[i]; j++){
printf("%c", '*');
}
printf("\n");
}
system("pause");
return 0;
}
#define SIZE 10
int main(void)
{
int n[SIZE] = {19, 3, 15, 7, 11, 9, 13, 5, 17, 1};
int i;
int j;
printf("%s%13s%17s\n","Element","Value", "Histogram");
for( i=0; i<SIZE; i++){
printf("%7d%13d ", i, n[i]);
for (j=1; j<= n[i]; j++){
printf("%c", '*');
}
printf("\n");
}
system("pause");
return 0;
}
Specifying an Array's Size with a Symbolic Constant and Initializing Array Elements with Calculations
#include<stdio.h>
#define SIZE 10
int main (void)
{
int s[SIZE];
int j;
for(j = 0; j<SIZE; j++){
s[j] = 2+2*j;
}
printf( "%s%13s\n", "Element", "Value");
for(j=0; j<SIZE; j++){
printf("%7d%13d\n",j, s[j]);
}
system ("pause");
return 0;
}
#define SIZE 10
int main (void)
{
int s[SIZE];
int j;
for(j = 0; j<SIZE; j++){
s[j] = 2+2*j;
}
printf( "%s%13s\n", "Element", "Value");
for(j=0; j<SIZE; j++){
printf("%7d%13d\n",j, s[j]);
}
system ("pause");
return 0;
}
Initializing the elemets of an array with an initializer list
#include<stdio.h>
int main (void)
{
int n[10] = {29, 8,19, 91, 28, 10, 19, 91, 0, 0 };
int i;
printf("%s%13s\n", "Element", "Value");
for( i= 0; i <10;i++){
printf("%7d%13d\n", i, n[i]);
}
system ("pause");
return 0;
}
int main (void)
{
int n[10] = {29, 8,19, 91, 28, 10, 19, 91, 0, 0 };
int i;
printf("%s%13s\n", "Element", "Value");
for( i= 0; i <10;i++){
printf("%7d%13d\n", i, n[i]);
}
system ("pause");
return 0;
}
Initializing the elemets of an array to zeros
#include<stdio.h>
int main (void)
{
int n[ 10 ]; /* n is array of 10 integers */
int i; /* counter */
/* initialize elemets of array n to 0 */
for ( i=0; i < 10; i++){
n[i]=0;
}
printf("%s%13s\n", "Element", "Value" );
for (i=0;i< 10; i++){
printf("%7d%13d\n", i, n[i]);
}
system ("pause");
return 0;
}
int main (void)
{
int n[ 10 ]; /* n is array of 10 integers */
int i; /* counter */
/* initialize elemets of array n to 0 */
for ( i=0; i < 10; i++){
n[i]=0;
}
printf("%s%13s\n", "Element", "Value" );
for (i=0;i< 10; i++){
printf("%7d%13d\n", i, n[i]);
}
system ("pause");
return 0;
}
How the Two-Stroke Engine Work
How the Engines Work
"Stroke" refers to the movement of the piston in the engine. 2 Stroke means one stroke in each direction. A 2 stoke engine will have a compression stroke followed by an explosion of the compressed fuel. On the return stroke new fuel mixture is inserted into the cylinder.
A 4 stroke engine has 1 compression stroke and 1 exhaust stoke. Each is followed by a return stroke. The compression stroke compresses the fuel air mixture prior to the gas explosion. The exhaust stroke simply pushes the burnt gases out the exhaust.
Resistance Calculator
#include<stdio.h>
#include<math.h>
int main (void)
{
int i, n, r, s;
double rt = 0.0;
printf( "How many Resistor you want ( less than 5 ) :" );
scanf( "%d", &n);
printf( "Do want them Parellel or series\n 1 Parallel\n 2 Series\n" );
scanf( "%d", &s);
swith (s){
case 1:
for ( i = 1; i <= n; i++ ) {
printf( "R%d =",i );
scanf( "%d", &r );
rt = rt + pow ( r, -1 );
}
printf( "the total resistance Rt = %2.2f", 1/rt );
break;
Change Position (Programming for Engineers)
#include<stdio.h>
int main (void)
{
int x, y, z;
scanf("%d", &x);
scanf("%d", &y);
z = x;
x = y;
y = z;
z = (y>x)? y:z;
printf("%d %d", x, y);
system("pause");
return 0;
}
int main (void)
{
int x, y, z;
scanf("%d", &x);
scanf("%d", &y);
z = x;
x = y;
y = z;
z = (y>x)? y:z;
printf("%d %d", x, y);
system("pause");
return 0;
}
Assignment 1 (Programming for Engineers)
Flowchart |
int main ()
{
int x = 0;
printf("\n\t _______________________________________________\n");
printf("\t|\t\t|\t\t|\t\t|");
printf("\n\t|\tNUMBER\t|\tSQUARED\t|\tCUBE\t\|\n");
printf("\t|_______________|_______________|_______________|\n");
while(x <=10)
{
int a, b, c;
printf("\t|\t\t|\t\t|\t\t|");
printf("\n\t|\t%d\t|\t%d\t|\t%d\t|\n", a, b, c);
printf("\t|_______________|_______________|_______________|\n");
x ++;
}
system ("pause");
return 0;
}
Output |
Control Statement
if else
#include<stdio.h>
int main()
{
int grade;
printf( "Enter your mark: " );
scanf("%d", &grade );
if ( grade>= 60 )
printf( "\nPass\n" );
else
printf( "\nFail\n" );
system ( "pause" );
return 0;
}
Output |
conditional operator ( :? )
#include<stdio.h>
int main()
{
int grade;
printf( "Enter your mark: " );
scanf("%d", &grade );
grade >= 60? printf( "Pass\n" ) : printf( "Fail\n" );
system ( "pause" );
return 0;
}
======================================================================
#include<stdio.h>
int main()
{
int grade;
printf( "Enter your mark: " );
scanf("%d", &grade );
printf( "%s", grade>=60? "Pass\n" : "Fail\n");
system ( "pause" );
return 0;
}
Supplication on finishing the ablution
Subscribe to:
Posts (Atom)