×
Create a new article
Write your page title here:
We currently have 276 articles on Waste Of Space Wiki. Type your article name above or create one of the articles listed here!



    Waste Of Space Wiki
    Revision as of 08:15, 23 January 2022 by Comedy this is a mirahez account (talk | contribs) (Created page with "{{Object|type=Logic|uses=Programming|malleability={{#invoke:GetPartInfo|getField|Malleability}}|recipe={{#invoke:GetPartInfo|getField|Recipe}}|raw_recipe={{#invoke:GetPartInfo|getField|Raw recipe}}}} == How to use a microcontroller == Microcontrollers are parts that are used to run code. You use the hammer tool to configure what it will run, however it is highly recommended to program somewhere else, such as notepad or roblox studio, and then copy and paste the code int...")
    (diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

    How to use a microcontroller

    Microcontrollers are parts that are used to run code. You use the hammer tool to configure what it will run, however it is highly recommended to program somewhere else, such as notepad or roblox studio, and then copy and paste the code into the configure. Note that if your code is more then 2000 characters long you will need to upload it to github and paste the raw link in the configure. Microcontrollers are turned on with polysilicon when powered. Below is a diagram showing how to use ports and ethernetcables.

    caption

    Microcontroller related parts

    Programming

    Microcontrollers run on Pilot.lua, which is basically just normal lua with a few things added to interact with the game.

    Microcontroller globals

    GetPartFromPort()

    Gets the first part it finds connected to the port

     GetPartFromPort(2, "Switch") --gets the first switch connected to the second port 
    

    TriggerPort()

    Sends a trigger signal from a port

     TriggerPort(5) --sends a trigger signal out of the 5th port 
    

    Beep()

    Makes the microcontroller beep

     Beep(1) --beeps with a pitch of 1 
    

    Parts

    :Configure()

    Configure can be run on any part. It works like configuring with hammer tool.

      local Switch = GetPartFromPort(2, "Switch") --gets the first switch connected to the second port 
    
    Switch:Configure( {SwitchValue = true} ) --sets the switch to be on  
    

    :Trigger()

    Simulates the part receiving a trigger signal

      local Anchor = GetPartFromPort(1, "Anchor") --gets the first anchor connected to the first port 
    
    Anchor:Trigger() --triggers the anchor  
    

    :ConnectToEvent()

    Connects to a parts event, such as a keyboard input.

      local Sign = GetPartFromPort(1, "Sign") --gets a sign
    
     local Keyboard = GetPartFromPort(2, "Keyboard") --gets a keyboard
    
    
    local function FuncName(text) --function that runs when keyboard gets input
    
        text = text:sub(1, -2) --removes the newline from pressing enter to confirm keyboard input
    
        Sign:Configure( { SignText = text } )
    
    end --ends the function
    
    
    Keyboard:ConnectToEvent("TextInputted", FuncName) --runs the function when keyboard gets input  
    

    i will add more later

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • 116.111.185.163 • 8 hours ago
  • 116.111.185.163 • 8 hours ago
  • 116.111.185.163 • 8 hours ago
  • 116.111.185.163 • 9 hours ago
  • Cookies help us deliver our services. By using our services, you agree to our use of cookies.