Results 1 to 8 of 8

Thread: Newbies and Coding

  1. #1
    Newbie
    Join Date
    Jun 2007
    Posts
    4

    Newbies and Coding

    I'm interested in beginning to code and write programs. I was wondering if there was any good books or pdf's that can teach me about the basics and what languages are good for what. Any help will be greatly greatly appreciated. Thanks guys

  2. #2
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,052
    Have you ever programmed before? Anything? Even maybe a TI-83/86/89?

    Because in my mind the most important part is learning how to make your idea of the final project into code not neccessarily the actual language.

    I would start with a procedural language (like C) and then after you get that all figured out move to OOP like C#. I personally hate VB but I wrote my very first code in "Blitz Basic". It is an awesome beginning language when paired with this book that came with it.

    The book is "Game Programming for Teens" by Maneesh Sethi. I believe there is a version 2 now, but I used version 1 and it was fine. So if you can find it dirt cheap somewhere, doesnt matter too much. You will only use it to get over the "thoughts to code". Once you get that down, the actual syntax of programs are easy and if you cant remember the keyword, newer languages do most of the work for you, and there is always google.

    I would start with the "hello world" program in C. Then try to make some sort of a switch/case (bunch of if this, then that, else if this, then that, and so on) based on user input. Something like enter a number, make sure it is number, and return the day of the week the number corresponds to in a textual format. Like you type 0 and it returns "Monday". You type "fkdsfds" and it returns "error".

    Also if you need any help with the C languages (C, C++, C#) I can help. I know others but not as well.

    Some will say why bother to learn C because it is so old (1972), but it puts a very nice foundation down. I think after you master pointers in C, you are ready to move up to C#. It will just all make sense more of how things work.
    Fusion Brain Version 6 Released!
    1.9in x 2.9in -- 47mm x 73mm
    30 Digital Outputs -- Directly drive a relay
    15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
    Buy now in the MP3Car.com Store

  3. #3
    Newbie
    Join Date
    Jun 2007
    Posts
    4
    Thanks for the info! that was a great introduction, and gave me most of what i needed to get started.
    I have just one more question...when you were talking about the "if, then" sequencing of programming... i was wondering (and i know its possible, but i want to know your input)... im looking to build something like the "if then" but instead of inputs that are done with a human, i want the programming to monitor inputs (like from a car sensor) and then give an output in voltage..which would then in turn activate a solenoid and so on (or basically whatever i needed). What language is this best suited for... (basically looking for almost real time output with little to no delay (if possible of course). any info, again, would be greatly appreciated.
    thanks!

  4. #4
    Newbie
    Join Date
    Jul 2005
    Posts
    44
    Depending on what you want to achieve with the car sensors and constant monitoring you might be better off not using a computer at all. U can probably make a very simple electronic logic circuit that will achieve the same thing or program a micro-controller (micro controller may start to get complicated though).

    I don't think that you'll find any language better or worse for sensor monitoring. You're basically describing a simple input -> calculate something -> output situation, this is the only thing that computers can do, so theoretically every language should be able to do it almost equally well.

    Spuzzdawg

  5. #5
    Super Moderator. If my typing sucks it's probably because I'm driving.... turbocad6's Avatar
    Join Date
    Oct 2004
    Location
    NY
    Posts
    6,234
    hey bubbajoe, not to discourage your desire to learn how to eventually do some of that programming, & then figuring out how to get these inputs & outputs rigged & configured, but have you seen this?

    the benifits there is you have a serious program behind it that can do all that you want & more, & you can have this all going in weeks rather than months & years or maybe never even becoming more than a passing thought, you may not need to have to learn how to reinvent the wheel when it's as easy as an interface like this

  6. #6
    Newbie
    Join Date
    Jun 2007
    Posts
    4
    thanks for the link. ya, ill prolly invest in a chip for starting projects...but id like to know how the programming works (well really, i was one of those kids that got a present and played with it for 2 secs, before blasting it apart to see how it worked...so i guess i want to know how everything works..and since programming is at the base of all electronics and computing, that would be the most obvious way.no?). Thanks again for the link...looks that is a diamond for those who want to finish a project quickly

  7. #7
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,052
    Quote Originally Posted by BubbaJoe13 View Post
    thanks for the link. ya, ill prolly invest in a chip for starting projects...but id like to know how the programming works (well really, i was one of those kids that got a present and played with it for 2 secs, before blasting it apart to see how it worked...so i guess i want to know how everything works..and since programming is at the base of all electronics and computing, that would be the most obvious way.no?). Thanks again for the link...looks that is a diamond for those who want to finish a project quickly
    Indeed it is.

    If you want to learn coding for microprocessors, then C or C++ is what you will be using.

    I thought you just wanted coding for the PC to make games, or applications. Drivers and integrated code is all completely different. There you cant use what is easiest, you have to use what is fastest and smallest. For instance, you shouldnt use a string to classify things, because a string is an array of characters.

    For instance in C#, if you wanted easy to read code you could say:
    Code:
    string thisThing = "Tree";
    switch(thisThing)
    {
         case "Tree":
              doTreeThing();
              break;
         case "Frog":
              doFrogThing();
              break;
         default:
              doUnknownThing();
              break;
    }
    each character in the string takes up as much space as an integer. And when you are dealing with storage spaces such as Gigabytes in modern computers, or 512Mb of RAM, this is no problem. However, when you get a PIC with 64Kb of memory, each byte matters.

    So instead you need:

    Code:
    /*
     * 0 = Tree
     * 1 = Frog
     ...
    */
    
    int thisThing = 0;
    switch(thisThing)
    {
         case 0:
              doTreeThing();
              break;
         case 1:
              doFrogThing();
              break;
         default:
              doUnknownThing();
              break;
    }
    takes up less space and is much faster, but it starts to get less human readable. The most basic you will probably go is assembly which is a nightmare to understand. I dont get it yet.

    When you do a if(string == string), it has to compare every single character. It is as if you had n number of if statements where n is the length of the string. So if("tree" == "there") it is actually:
    Code:
    if(char1a == char1b) {
         if(char2a == char2b) {
              if(char3a == char3b) {
                   if(char4a == char4b) {
                        if(char5a == char5b) {
                             return true;
                        } else {
                             return false;
                        }
                   }  else {
                        return false;
                   }
              } else {
                   return false;
              }
         } else {
              return false;
         }
    } else {
         return false;
    }
    that is when it executes it. Instead of just 1 if statement for an integer. It doesnt actually work just like that above, but it does have that many more comparisons because a string is just an array.

    So anyways, there are completely different styles of codes for microproccessor coding, and general computer coding.
    Fusion Brain Version 6 Released!
    1.9in x 2.9in -- 47mm x 73mm
    30 Digital Outputs -- Directly drive a relay
    15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
    Buy now in the MP3Car.com Store

  8. #8
    Maximum Bitrate galvitron's Avatar
    Join Date
    Mar 2007
    Location
    Socal
    Posts
    719
    You will also want to read about the basic elements of programs like a main function and how to compile. Understand what a function is and how variables are passed and returned. Also, understand how basic structures work like arrays, stacks, fifo and lifo stuff. Practice having functions call other functions. Then move on to pointers. This is difficult for many people but just requires patience.

    Look at example code around the net and you will get good ideas on how to write code that you think is organized and clear. Remember that one day someone else may be reading it and they don't know that variable z is a pointer to an integer, etc.
    2006 Lancer Evolution IX MR In-Dash PC Project - WIP

    Planning:
    [----------] 100%
    Purchasing:
    [----------] 90%
    Installation/Fab/Assembly (Revised v2):
    [----------] 90%


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •