SlideShare a Scribd company logo
1 of 1
#pragma config(Sensor, S1,      HTMAG,              sensorRawValue)

#include "drivers/HTMAG-driver.h"

task main(){
  int readValue;
  int displayValue;
  int maxReadValue;
  float devideBy = 2.6;
  int sensorValues[100];
  int i;

    nMotorEncoder[motorA] = 0;
    nxtDisplayCenteredTextLine(3, "press orange");
    nxtDisplayCenteredTextLine(4, "to configure");
    while(nNxtButtonPressed == -1){}
    if(nNxtButtonPressed == 3){
      eraseDisplay();
      while(nNxtButtonPressed == 3){}
      HTMAGstartCal(HTMAG);
    }
    while(true){
      devideBy = (nMotorEncoder[motorA]/10)+2.6;
      readValue = HTMAGreadVal(HTMAG);
      displayValue = readValue/devideBy;
      sensorValues[99] = displayValue*0.52;
      for(i=0; i<100; i++){
        if(i != 99){
          sensorValues[i] = sensorValues[i+1];
        }
      }
      if(readValue > maxReadValue){
        maxReadValue = readValue;
      }
      eraseDisplay();
      for(i=0; i<100; i++){
        nxtDrawLine(i, 0, i, sensorValues[i]);
      }
      nxtDisplayStringAt(0, 63, "                 ");
      nxtDisplayStringAt(3, 63, "Max: %3d", maxReadValue);
      nxtDisplayStringAt(82, 63, "%f", devideBy);
      wait10Msec(20);
    }
}

More Related Content

What's hot

10CSL67 CG LAB PROGRAM 10
10CSL67 CG LAB PROGRAM 1010CSL67 CG LAB PROGRAM 10
10CSL67 CG LAB PROGRAM 10Vanishree Arun
 
10CSL67 CG LAB PROGRAM 8
10CSL67 CG LAB PROGRAM 810CSL67 CG LAB PROGRAM 8
10CSL67 CG LAB PROGRAM 8Vanishree Arun
 
The Ring programming language version 1.2 book - Part 40 of 84
The Ring programming language version 1.2 book - Part 40 of 84The Ring programming language version 1.2 book - Part 40 of 84
The Ring programming language version 1.2 book - Part 40 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88Mahmoud Samir Fayed
 
Trip itparsing
Trip itparsingTrip itparsing
Trip itparsingCapIpad
 
The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 63 of 212
The Ring programming language version 1.10 book - Part 63 of 212The Ring programming language version 1.10 book - Part 63 of 212
The Ring programming language version 1.10 book - Part 63 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210Mahmoud Samir Fayed
 
10CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 710CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 7Vanishree Arun
 
The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84Mahmoud Samir Fayed
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++Ankit Kumar
 
The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189Mahmoud Samir Fayed
 
Mongo db world 2014 billrun
Mongo db world 2014   billrunMongo db world 2014   billrun
Mongo db world 2014 billrunMongoDB
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 

What's hot (20)

Include
IncludeInclude
Include
 
10CSL67 CG LAB PROGRAM 10
10CSL67 CG LAB PROGRAM 1010CSL67 CG LAB PROGRAM 10
10CSL67 CG LAB PROGRAM 10
 
Funcion matematica
Funcion matematicaFuncion matematica
Funcion matematica
 
10CSL67 CG LAB PROGRAM 8
10CSL67 CG LAB PROGRAM 810CSL67 CG LAB PROGRAM 8
10CSL67 CG LAB PROGRAM 8
 
The Ring programming language version 1.2 book - Part 40 of 84
The Ring programming language version 1.2 book - Part 40 of 84The Ring programming language version 1.2 book - Part 40 of 84
The Ring programming language version 1.2 book - Part 40 of 84
 
Asssignment2
Asssignment2 Asssignment2
Asssignment2
 
The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88
 
Trip itparsing
Trip itparsingTrip itparsing
Trip itparsing
 
Vcs9
Vcs9Vcs9
Vcs9
 
Android Animation (in tamil)
Android Animation (in tamil)Android Animation (in tamil)
Android Animation (in tamil)
 
The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181The Ring programming language version 1.5.2 book - Part 52 of 181
The Ring programming language version 1.5.2 book - Part 52 of 181
 
The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88
 
The Ring programming language version 1.10 book - Part 63 of 212
The Ring programming language version 1.10 book - Part 63 of 212The Ring programming language version 1.10 book - Part 63 of 212
The Ring programming language version 1.10 book - Part 63 of 212
 
The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210
 
10CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 710CSL67 CG LAB PROGRAM 7
10CSL67 CG LAB PROGRAM 7
 
The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84The Ring programming language version 1.2 book - Part 39 of 84
The Ring programming language version 1.2 book - Part 39 of 84
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
 
The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189
 
Mongo db world 2014 billrun
Mongo db world 2014   billrunMongo db world 2014   billrun
Mongo db world 2014 billrun
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 

Similar to Magnetic grapher-coding

Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdffashiongallery1
 
#include stdio.h #include stdlib.h #include unistd.h .pdf
 #include stdio.h #include stdlib.h #include unistd.h .pdf #include stdio.h #include stdlib.h #include unistd.h .pdf
#include stdio.h #include stdlib.h #include unistd.h .pdfnipuns1983
 
Async Testing giving you a sinking feeling
Async Testing giving you a sinking feelingAsync Testing giving you a sinking feeling
Async Testing giving you a sinking feelingErin Zimmer
 
#include stdio.h #include stdlib.h #include time.hdouble.pdf
#include stdio.h #include stdlib.h #include time.hdouble.pdf#include stdio.h #include stdlib.h #include time.hdouble.pdf
#include stdio.h #include stdlib.h #include time.hdouble.pdfarjunchetri1
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointersvinay arora
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C ProgramsKandarp Tiwari
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPGFrankDin1
 
Program for hamming code using c
Program for hamming code using cProgram for hamming code using c
Program for hamming code using csnsanth
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfshreeaadithyaacellso
 
Include stdio. wps office (1)
Include  stdio. wps office (1)Include  stdio. wps office (1)
Include stdio. wps office (1)NilayChavhan
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲームNoritada Shimizu
 
Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018Peter Meyer
 

Similar to Magnetic grapher-coding (20)

SaraPIC
SaraPICSaraPIC
SaraPIC
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
 
#include stdio.h #include stdlib.h #include unistd.h .pdf
 #include stdio.h #include stdlib.h #include unistd.h .pdf #include stdio.h #include stdlib.h #include unistd.h .pdf
#include stdio.h #include stdlib.h #include unistd.h .pdf
 
Async Testing giving you a sinking feeling
Async Testing giving you a sinking feelingAsync Testing giving you a sinking feeling
Async Testing giving you a sinking feeling
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Statistics.cpp
Statistics.cppStatistics.cpp
Statistics.cpp
 
#include stdio.h #include stdlib.h #include time.hdouble.pdf
#include stdio.h #include stdlib.h #include time.hdouble.pdf#include stdio.h #include stdlib.h #include time.hdouble.pdf
#include stdio.h #include stdlib.h #include time.hdouble.pdf
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
array
arrayarray
array
 
Osla b manual
Osla b manualOsla b manual
Osla b manual
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPG
 
Program for hamming code using c
Program for hamming code using cProgram for hamming code using c
Program for hamming code using c
 
Unix Programs
Unix ProgramsUnix Programs
Unix Programs
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdf
 
Include stdio. wps office (1)
Include  stdio. wps office (1)Include  stdio. wps office (1)
Include stdio. wps office (1)
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲーム
 
Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018
 

Magnetic grapher-coding

  • 1. #pragma config(Sensor, S1, HTMAG, sensorRawValue) #include "drivers/HTMAG-driver.h" task main(){ int readValue; int displayValue; int maxReadValue; float devideBy = 2.6; int sensorValues[100]; int i; nMotorEncoder[motorA] = 0; nxtDisplayCenteredTextLine(3, "press orange"); nxtDisplayCenteredTextLine(4, "to configure"); while(nNxtButtonPressed == -1){} if(nNxtButtonPressed == 3){ eraseDisplay(); while(nNxtButtonPressed == 3){} HTMAGstartCal(HTMAG); } while(true){ devideBy = (nMotorEncoder[motorA]/10)+2.6; readValue = HTMAGreadVal(HTMAG); displayValue = readValue/devideBy; sensorValues[99] = displayValue*0.52; for(i=0; i<100; i++){ if(i != 99){ sensorValues[i] = sensorValues[i+1]; } } if(readValue > maxReadValue){ maxReadValue = readValue; } eraseDisplay(); for(i=0; i<100; i++){ nxtDrawLine(i, 0, i, sensorValues[i]); } nxtDisplayStringAt(0, 63, " "); nxtDisplayStringAt(3, 63, "Max: %3d", maxReadValue); nxtDisplayStringAt(82, 63, "%f", devideBy); wait10Msec(20); } }