Anonymní profil Milos – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil Milos – Programujte.comAnonymní profil Milos – Programujte.com

 

Příspěvky odeslané z IP adresy 62.197.243.–

Milos
Mikrokontroléry › mer. sinus. napatia - uklada…
10. 4. 2016   #209846

Ahojte, potreboval by som poradit od skusenejsich.
Meriam sinusovy signal, ktory nadobuda hodnoty z AD prevodnika 56 az 145 a casom sa amplituda zmensuje (napr. v urcitom case bude mat 70 az 120). to co by som potreboval je algoritmus (funkciu) ktorou by som do nejakej premennej ukladal najvyssiu hodnotu z takehoto intervalu. 

Pri spusteni si ulozim povedzme najvyssiu hodnotu 145 potom zacne amplituda klesat a pri hodnote 120 zopnem napr. nejaky vystup.

Dakujem  za cenne rady

Milos
Visual Basic › Priesecnik usecky a elipsy
8. 5. 2014   #189921

Ahojte, prosím vás o pomoc. Potrebujem v malom programe vykreslovať úsečku a elipsu zadaním ich parametrov a ak maju nejaký priesečník, tak vypísať súradnice priesečníku. Niečo som nakódil, ale nefunguje to dobre. 

Ďakujem

Public Class Form1
    Public a, aa, b, bb, h, k, x1, y1, x2, y2, m, xi1, yi1, xi2, yi2, c, cc, d As Single
    Public mypen As Pen
    Public farba As Char = "0"
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

    End Sub

    Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
        x1 = TextBox5.Text
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
        If farba = "1" Then mypen = New Pen(Drawing.Color.Red, 5)
        If farba = "2" Then mypen = New Pen(Drawing.Color.Green, 5)
        If farba = "3" Then mypen = New Pen(Drawing.Color.Yellow, 5)
        If farba = "4" Then mypen = New Pen(Drawing.Color.Blue, 5)
        If farba = "5" Then mypen = New Pen(Drawing.Color.Black, 5)
        If farba = "0" Then mypen = New Pen(Drawing.Color.Black, 5)

        Dim myGraphics As Graphics = Me.CreateGraphics
        myGraphics.DrawEllipse(mypen, a, b, h, k)
        myGraphics.DrawLine(mypen, x1, y1, x2, y2)

        EllipseIntersectLine()
        MsgBox(xi1)
        MsgBox(yi1)
        MsgBox(xi2)
        MsgBox(yi2)


    End Sub

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged
        y1 = TextBox6.Text
    End Sub

    Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
        x2 = TextBox7.Text
    End Sub

    Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
        y2 = TextBox8.Text
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        a = TextBox1.Text
    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        b = TextBox2.Text
    End Sub

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
        h = TextBox3.Text
    End Sub

    Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
        k = TextBox4.Text
    End Sub

    Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.Text = "Červená" Then farba = "1"
        If ComboBox1.Text = "Zelená" Then farba = "2"
        If ComboBox1.Text = "Žltá" Then farba = "3"
        If ComboBox1.Text = "Modrá" Then farba = "4"
        If ComboBox1.Text = "Čierna" Then farba = "5"
    End Sub

    Private Sub Label7_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label7.Click

    End Sub

    Private Sub EllipseIntersectLine()

        If (x1 <> x2) Then

            m = (y2 - y1) / (x2 - x1)
            c = y1 - m * x1

            aa = a * b + a * a * m * m
            bb = 2 * a * a * c * m - 2 * a * a * k * m - 2 * h * b * b
            cc = b * b * h * h + a * a * c * c - 2 * a * a * k * c + a * a * k * k - a * a * b * b

        Else

            aa = a * a
            bb = -2.0 * k * a * a
            cc = -a * a * b * b + b * b * (x1 - h) * (x1 - h)

        End If

        d = bb * bb - 4 * aa * cc

        If (d > 0) Then


            If (x1 <> x2) Then


                xi1 = (-bb + Math.Sqrt(d)) / (2 * aa)
                xi2 = (-bb - Math.Sqrt(d)) / (2 * aa)
                yi1 = y1 + m * (xi1 - x1)
                yi2 = y1 + m * (xi2 - x1)

            Else

                yi1 = (-bb + Math.Sqrt(d)) / (2 * aa)
                yi2 = (-bb - Math.Sqrt(d)) / (2 * aa)
                xi1 = x1
                xi2 = x1
            End If

        Else
            MsgBox("nenastal prienik")

        End If

    End Sub
    
    Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged

    End Sub
End Class

Milos
Visual Basic › posielanie hodnoty premennej…
4. 3. 2014   #187875

#3 Milos
skusal som ju deklarovat aj v Form_Load() ale nejde to stale

Milos
Visual Basic › posielanie hodnoty premennej…
4. 3. 2014   #187873

#2 ing
 

mám to takto, ale stále to nefunguje. Ak premennej pridelím nejaku hodnotu viď. "príklad" tak to funguje. Som akosi bezradný.

Private Sub Command1_Click()
Dim Striekacka As Byte

"príklad" Striekacka = 2
If Striekacka = 0 Then MSComm1.Output = "je nulovy"
If Striekacka = 2 Then MSComm1.Output = "2"
If Striekacka = 5 Then MSComm1.Output = "5"
If Striekacka = 10 Then MSComm1.Output = "10"
If Striekacka = 15 Then MSComm1.Output = "15"
If Striekacka = 20 Then MSComm1.Output = "20"
If Striekacka = 50 Then MSComm1.Output = "50"
End Sub

Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "2400,n,8,1"
MSComm1.PortOpen = True
End Sub

Private Sub Option1_Click()
Striekacka = 2
End Sub

Private Sub Option2_Click()
Striekacka = 5
End Sub

Private Sub Option3_Click()
Striekacka = 10
End Sub

Private Sub Option4_Click()
Striekacka = 15
End Sub

Private Sub Option5_Click()
Striekacka = 20
End Sub

Private Sub Option6_Click()
Striekacka = 50
End Sub

Private Sub tmrTimer_Timer()
txtDisplay.Text = txtDisplay.Text + Chr(13) + MSComm1.Input
End Sub

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032020 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý